0

I have requirement where I have to stop and start message consumer based on condition. If startConsumer flag is set true, then consumer should start consuming messages and if startConsumer is set to false then consumer should stop consuming messages, similar to following question

How can I Stop/start/Pause a @JmsListener (the clean way)

But I could not find the way how to configure JmsListenerEndpointRegistry bean so that I can call stop/start method on it. I googled a lot but no sample is found in which this bean configuration is shown. The only examples are from spring docs and in that also there is no configuration sample. Below is my bean definition

<<bean id="jmsListenerEndpointRegistry" class="org.springframework.jms.config.JmsListenerEndpointRegistry">
// what should be here to properly configure it?
    </bean>

When I call method on this bean object, it has no reference of container. enter image description here

Please Note that I am not using spring boot and hence this bean is not automatically configured.

Any help is very much appreciated.

Thanks

PS.

Vishal Singh
  • 624
  • 1
  • 5
  • 16
  • Please explain the usecase not the technical solution you are trying to solve. What do you need to set? Generally you should be configuring the listener containers not the registry. – M. Deinum Nov 17 '22 at 12:54
  • 1
    You don't need anything to configure it, it will automatically detect the beans. Also if this is a condition based on a flag at startup you are still better of configuring the listener container and not the registry. – M. Deinum Nov 21 '22 at 08:27
  • @M.Deinum, yes it is automatically detected, but when I use JmsListner annotation on the consumer bean. I was looking for its equivalent configuration through xml i.e. how to define message container through xml without using JmsListner annotation and it is still detectable by JmsListenerEndpointRegistry – Vishal Singh Dec 09 '22 at 10:53
  • I even don't JmsListenerEndpointRegistry . Container can be directly get from xml bean definition and start/stop methods can be directly called on it. Thanks @M.Deinum, for reviewing question and sharing your knowledge. – Vishal Singh Dec 09 '22 at 12:24

0 Answers0