== Validator - Spring Boot example

=== Abstract

This example shows how to work with a simple Apache Camel application using Spring Boot with declarative content validation enabled.

=== Introduction

The example generates messages using timer trigger, writes them to standard output. The output type is declared as `greeting`, which has corresponding validator defined.

=== Camel routes

The Camel route is located in the `SampleCamelRouter` class. In this class the route
starts from a timer, that triggers every 2nd second and calls a Spring Bean `SampleBean`
which returns a message, that is routed to a log endpoint which writes to standard output.
The output type is declared as `greeting`, and the validator `GreetingValidator` is registered
to be triggered for `greeting` output message right after the routing. 

=== Using Camel components

Apache Camel provides 200+ components which you can use to integrate and route messages between many systems
and data formats. To use any of these Camel components, add the component as a dependency to your project.

=== How to run

You can run this example using

    mvn spring-boot:run

You can run this example with validation failure using

    mvn spring-boot:run -Dspring-boot.run.arguments=Hello_Mars

=== How to run on Openshift

Create your own project

    oc new-project csb-example-validator

So you can deploy and run with the command

    mvn clean package -Popenshift -Dgreeting=Hello_World -DskipTests

You can run this example with validation failure using

    mvn clean package -Popenshift -Dgreeting=Hello_Mars -DskipTests

=== Shutdown policies example (on Openshift)

Given that by default terminationGracePeriodSeconds is 30 seconds and camel.main.shutdown-timeout is 45, this example shows how to configure both of them so that the pod is not killed before the shutdown-timeout:

in _src/main/jkube/deployment.yml_ we can configure the Pod graceful termination period

    spec:
      template:
        spec:
          containers:
             # ...
      terminationGracePeriodSeconds: 60 # default is 30

On the application side we need to add some properties to set and verify the desired camel route shutdown using the camel *DefaultShutdownStrategy* feature:

_src/main/resources/application.properties_

    # increase graceful shutdown timeout to 60 seconds (default is 45)
    camel.main.shutdown-timeout = 60 # (default is 45)
    camel.springboot.shutdown-timeout = 60

    # monitoring the DefaultShutdownStrategy behaviour
    logging.level.org.apache.camel.impl.engine.DefaultShutdownStrategy = DEBUG

=== Help and contributions

If you hit any problem using Camel or have some feedback, then please
https://camel.apache.org/support.html[let us know].

We also love contributors, so
https://camel.apache.org/contributing.html[get involved] :-)

The Camel riders!
