How to dynamically change the destination queue while using DefaultMessageListenerConatiner?

Viewed 92

I have configured a listener using DynamicMessageListenerContainer and configured it to listen to a particular queue/destination with a timeout of 5 seconds.

Once that timeout is achieved I want to toggle listening to another queue and then back to the original after next timeout.

Spring's documentation says it is possible but it is considered as advanced usage, I could not find how to do it.

Any help would be appreciated.

Thank you

1 Answers

It's a rather unusual requirement; why not simply configure two containers? However...

container.stop();
contaner.shutdown();
container.setDestination(...); (or setDestinationName())
container.initialize();
container.start();

...not very efficient - especially if you are doing it every 5 seconds, but it should work.

Related