I'm a newbie around but I'll try to be consice.
{INPUT QUEUE}->[INBOUND-GATEWAY-1]-->[ROUTER]----------->(ACTIVATOR)<--------------- \ / \-->{HOLD QUEUE}--->[INBOUND-GATEWAY-2]--^
I'm having an scenario in which I have to dynamically change routing conditions in a flow like the former. Messages comming from a queue are sent to an activator to be processed, or another queue to be put on hold. At certain time, I have to close INBOUND-GATEWAY-1 so no new messages come into the flow, and open INBOUND-GATEWAY-2 to let all messages from HOLD QUEUE be processed. Once all messages from HOLD QUEUE were been consumed, both gateways must me closed/opened as they were before. The thing here is how could I know when HOLD QUEUE is empty so I could trigger a method in which gateway-1 could be started?
I'd be grateful if somebody could help me.
Thanks in advance
After some debugging and reading, finally I came to a solution for this issue. An inbound-gateway is a JmsMessageDrivenEndpoint, based in two inner components, a MessageListenerContainer and a MessageListener. MessageListenerContainer is the one in charge at scheduling MessageListener behaviour so, overriding the noMessageReceived and messageReceived, and adding some attributes to control the desired behaviour, I could be able to do the "magic".
My MessageListenerContainer implementation got like this.
And finally, the spring bean config get like this:
Hope this could be helpful for someone else.
Thanks to @Nicholas for the clues.
I would put this functionality into the inbound gateway processors. For example:
Gateway1Processor:
Gateway2Processor:
Therefore, the operating sequence would be: