Search code examples
javaapache-camelactivemq-classicatomikos

Adding delay to Camel route causes an Atomikos timeout


I have a Camel route that listens to an ActiveMQ. I have added a delay of 10 seconds to because it needs to be certain that another process has completed before commencing. This has been achieved by adding the delayer attribute: -

<camel:route id="packageRetrievalContentAndSendToS3" delayer="10000">
    <camel:from uri="activemq:{{ccs.activemq.queue.prefix}}.sr.package.and.send"/>

    ....extra steps....

</camel:route>

This works fine, but the trouble is, my route now times out! Message below.

Atomikos:8] c.a.icatch.imp.ActiveStateHandler        : Timeout/setRollbackOnly of ACTIVE coordinator !

I would really appreciate any advice as to how to address this. Ideally I would like to increase the timeout on that route. Many thanks


Solution

  • As @sergei-petunin already commented, you try to compensate a design issue by waiting.

    Your route should not receive a message before the thing you wait for is finished. That means that

    1. the thing you wait for receives a message and does what it has to do
    2. then it sends a message to your route
    3. then your route processes the message without waiting

    So all partial steps of the process are done asynchronous and sequentially because they depend on each other. This is also known as the Pipes and Filters EIP.

    If you have control over the thing you wait for, you can easily change the design by putting a message queue between the thing you wait for and your route.