Thursday, 5 September 2013

How to detect broken/recovered JMS connection in Apache Camel?

How to detect broken/recovered JMS connection in Apache Camel?

We are building an integration project using Apache Camel (Camel 2.10.3,
Java DSL based).
We have a route that extracts data from a database (lets call it IN_DB),
does some logic and inserts into another database (OUT_DB) once a day, and
another route that subscribes to a JMS topic for XML data, does some logic
and inserts it into the same database (OUT_DB) throughout the day.
The requirement is that when the JMS topic connection goes down for
whatever reason, we keep trying to reconnect indefinitely, and once
reconnection is successful we need to go back to the database (IN_DB) and
do another load to fill in the gap where the topic was down.
My question is how can we do this logic ('I was connected then I got
disconnected and now I am connected again') in Camel? What happens to the
route that starts with a topic consumer when the topic goes down, will the
route just stop? Or will it issue an error message to some error queue? Do
I have to write my own handler to monitor the topic connection, or will
Camel automatically reconnect when the topic comes back up and set some
message header, or set some context variable to indicate that the 'I was
connected then I got disconnected and now I am connected again' scenario
has happened? I am happy building the route logic around calling the
database load I just can't figure out the best way to 'detect' in Camel
that this scenario has happened.
Any suggestions much appreciated.

No comments:

Post a Comment