JmsTemplate
uses the JMS API behind the scene and in particular the MessageConsumer
. That service can either attempt to receive a Message
without waiting (receiveNoWait
) or it can wait a configurable amount of time (receive(long timeout)
). When it's being invoked with a timeout of 0, the receive method blocks until a message arrives. There's nothing in JmsTemplate
that deals with all this (i.e. it is provided by the client broker implementation).
A more regular way of receiving messages is to use a listener container. With Spring, the DefaultMessageListenerContainer
allows you to use a thread poll to process incoming messages. Check the jms documentation of the Spring framework for more information.