user2164711
user2164711

Reputation: 35

How can I exit a Spring Camel application when no messages are received at an endpoint for x seconds

I'm trying to configure a standalone spring-camel application so that there is a route, and if no messages are received on that route for x seconds, the whole context will shutdown.

Let's say x is 10, if no message is received for 8 seconds, but then one arrives on the route, the counter should reset to 10 seconds. Once the counter reaches 0, the whole app should exit (gracefully, finishing whatever routes are currently processing)

If messages keep coming within the 10 seconds, the app should never exit.

Does anyone know an elegant way to achieve this?

Upvotes: 1

Views: 840

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55750

If you use latest Camel release 2.19.1, you can then configure it to terminate after X messages, X time, or being idle for more than X seconds.

You can find the options in the camel spring configuration, which you can configure in application.properties for Spring, such as

https://github.com/apache/camel/blob/master/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java#L179

https://github.com/davsclaus/camel-profile-sample/blob/master/src/main/resources/application.properties#L24

Upvotes: 3

Related Questions