I have a server side application that consumes message from an JMS queue. I use Spring listener container like this:
<jms:listener-container connection-factory="myConnectionFactory"
..........
concurrency="4-8">
<jms:listener id="myListener" destination="my.ems.queue" ref="listenerBean" method="method"/>
</jms:listener-container>
This works fine.
One problem of this is that the listener starts to consume JMS message as soon as it is setup. However, some of the beans the listenerBean
depends take some time to initialize (It needs to populate some data from database).
Therefore, if the service starts up with some pending JMS message in the queue, it will try to serve it before data is populated completed. This causes some error.
My question is that how can I not start listener automatically until a later stage when data is fully populated, so that I can call the start()
method to manually start it?