问题
I am using the default shutdown strategy in my camelcontext. The route starts with a rabbitmq consumer which is consuming from a queue with more than 10k messages. When I stop the route, the consumer keeps on consuming new messages from the queue. Hence the inflight exchange count never decrements and the route waits for shutdown until the default timeout value(300s). Is there any way to change this behaviour? Basically stop the rabbitmq consumer from consuming new messages when shutdown is in progress.
回答1:
It is a good idea to keep the timeout during the shutdown of your route as it will allow time for a graceful shutdown of your route and if it is not able to gracefully do the shutdown then it will then force it to complete. Below are a couple links to more information about using the Default Shutdown Strategy.
https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.1/html-single/Apache_Camel_Development_Guide/#BasicPrinciples-StartupShutdown
http://camel.apache.org/graceful-shutdown.html
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/impl/DefaultShutdownStrategy.html
In the last link I would recommend looking at the ShutdownRunningTask section of the document as it seams you are running a consumer that is consuming like a batch consumer.
回答2:
I have the same the problem with you. The point is when shutting down, Camel prefer suspending consumers than shutting down them. Currently RabbitMQ consumer does not implement the suspend() method. The problem will be fix in version 2.16.2
来源:https://stackoverflow.com/questions/30396317/camel-shutdownstrategy-inflight-messages-do-not-decrease