Given I have ActiveMQ queue where many messages are already present.
When I set receive timeout on JmsTemplate
to RECEIVE_TIMEOUT_NO_WAIT
which is equal to -1
:
jmsTemplate.setReceiveTimeout(JmsTemplate.RECEIVE_TIMEOUT_NO_WAIT);
and try to receive one of those messages:
Message msg = jmsTemplate.receive(queueName);
then msg
is null
, but it should not be according JavaDoc:
/**
* Timeout value indicating that a receive operation should
* check if a message is immediately available without blocking.
*/
public static final long RECEIVE_TIMEOUT_NO_WAIT = -1;
Why is that?
When I do:
jmsTemplate.setReceiveTimeout(1000);
then messages are retrieved.