Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling connection failures in apache-camel

I am writing an apache-camel RabbitMQ consumer. I would like to react somehow to connection problems (i.e. try to reconnect). Is it possible to configure apache-camel to automatically reconnect?

If not, how can I find out that a connection to the queue was interrupted? I've done the following test:

  • start the queue (and some producer)
  • start my consumer (it was getting messages as expected)
  • stop the queue (the messages stopped arriving, as expected, but no exception was thrown)
  • start the queue (no new messages were received)

I am using camel in Scala (via akka-camel), but a Java solution would be probably also OK

like image 474
jfu Avatar asked Oct 21 '22 10:10

jfu


1 Answers

You can pass in the flag automaticRecoveryEnabled=true to the URI, Camel will reconnect if the connection is lost.

like image 93
Jimmy Au Avatar answered Oct 23 '22 01:10

Jimmy Au