Hi,

I know the way I am doing it might be a bit off from what is considered
normal, however I couldn't do it any other way.

I have a queue of user actions to be executed on the system.
There are several concurrent listeners listening for the actions, and they
take them off the queue and 'execute' them.
If an action is executed for a user and another comes in for the same user
it cannot be executed and has to wait for the first one to be completed.
I would normally use ActiveMQ redelivery policy and have it done in a sec,
however with redelivery policy delay the listener is blocked. I cannot have
that. When one action is waiting same listener can execute few other actions
and just increasing the number of concurrent listeners is not the way to go
for me.
To add some complexity to the process, after the action is finished I am
sending a response back to thread which created the first message. I am
using Spring and MessageListenerAdapter so it's pretty straight forward to
do it.

Now. In order to get around the delay I decided to use Camel delay pattern.
I execute my custom bean to calculate the delay and thanks to the fact that
all messages are delayed by the same amount of time messages are always
delayed the way I want. To achieve that I had to resign from redelivery
handling in ActiveMQ and I have it set to maximumRedeliveries = - and
initialRedeliveryDelay = 0. Camel listens on ActiveMQ.DLQ queue and resends
the messages to the original queue.

Here's how it works:

Start -> message sent to ActionQueue -> check if action can be executed:
Yes -> action is executed -> response sent back      <- this works fine

No -> transaction is rolled back -> ActiveMQ redelivery kicks in and sends
message to ActiveMQ.DLQ -> camel picks up the message -> message delayed ->
message sent to ActionQueue

Unfortunately, after the message is sent to ActionQueue and is picked up by
the listener, the response to this message never reaches the caller.

I ran my app with debug logging and can see that when message is rerouted
the reply-to queue changes.

Is there any way I could get this to work?

Thanks,
Krystian
-- 
View this message in context: 
http://camel.465427.n5.nabble.com/Cannot-reply-to-a-message-routed-by-camel-tp3254431p3254431.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.

Reply via email to