You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Yohan Liyanage <yo...@gmail.com> on 2008/07/11 13:47:11 UTC

Spring JmsTemplate receive() returns null with messages in Queue

Hi,

I tried to use JmsTemplate's receive() method for synchronous consumption of
a Queue, but the method returns 'null', even when there are messages in the
queue.

The JmsTemplate (with a time out of two seconds) successfully receives first
messages, but after a while, it is not able to consume messages from the
queue, and returns null (timeout), even when there are messages in the Queue
(I checked through JMX).

Then I tried using RECEIVE_TIMEOUT_INDEFINITE_WAIT, and with that, I was
able to consume about 7,8 messages (out of 50) and again, it fails returning
null. Then I tried out with NO_WAIT and this time, I was only able to
consume first message. It fails returning nulls.

I tried this with CachingConnectionFactory / SingleConnectionFactory and
also with direct ActiveMQ  ConnectionFactory. But the result is same. The
application consumes several messages, and then starts to return null, while
there are messages left in queue.

I am using Spring 2.5.5 with ActiveMQ 5.1.

Any suggestions are deeply appreciated.

Thanks

PS: I tried this with asynchronous message consumption using MessageListener
and DefaultMessageListenerContainer, and it works as expected without this
issue. 
-- 
View this message in context: http://www.nabble.com/Spring-JmsTemplate-receive%28%29-returns-null-with-messages-in-Queue-tp18402053p18402053.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Spring JmsTemplate receive() returns null with messages in Queue

Posted by kpalania <kp...@yahoo.com>.
I am running onto the same issue as well with ActiveMQ 5.1 and Spring 2.5. If
I don't use JmsTemplate or use it but do a blocking call, it is fine.
However, I am unable to use JmsTemplate with it being non-blocking. Any
thoughts?


Yohan Liyanage wrote:
> 
> Hi,
> 
> I tried to use JmsTemplate's receive() method for synchronous consumption
> of a Queue, but the method returns 'null', even when there are messages in
> the queue.
> 
> The JmsTemplate (with a time out of two seconds) successfully receives
> first messages, but after a while, it is not able to consume messages from
> the queue, and returns null (timeout), even when there are messages in the
> Queue (I checked through JMX).
> 
> Then I tried using RECEIVE_TIMEOUT_INDEFINITE_WAIT, and with that, I was
> able to consume about 7,8 messages (out of 50) and again, it fails
> returning null. Then I tried out with NO_WAIT and this time, I was only
> able to consume first message. It fails returning nulls.
> 
> I tried this with CachingConnectionFactory / SingleConnectionFactory and
> also with direct ActiveMQ  ConnectionFactory. But the result is same. The
> application consumes several messages, and then starts to return null,
> while there are messages left in queue.
> 
> I am using Spring 2.5.5 with ActiveMQ 5.1.
> 
> Any suggestions are deeply appreciated.
> 
> Thanks
> 
> PS: I tried this with asynchronous message consumption using
> MessageListener and DefaultMessageListenerContainer, and it works as
> expected without this issue. 
> 

-- 
View this message in context: http://www.nabble.com/Spring-JmsTemplate-receive%28%29-returns-null-with-messages-in-Queue-tp18402053p20097145.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Spring JmsTemplate receive() returns null with messages in Queue

Posted by tjhaz <tj...@autozone.com>.
I have noticed that this problem does not occur on the nightly builds of
activemq.  DId you ever find out anything about this issue?

Thanks


Yohan Liyanage wrote:
> 
> Hi,
> 
> I tried to use JmsTemplate's receive() method for synchronous consumption
> of a Queue, but the method returns 'null', even when there are messages in
> the queue.
> 
> The JmsTemplate (with a time out of two seconds) successfully receives
> first messages, but after a while, it is not able to consume messages from
> the queue, and returns null (timeout), even when there are messages in the
> Queue (I checked through JMX).
> 
> Then I tried using RECEIVE_TIMEOUT_INDEFINITE_WAIT, and with that, I was
> able to consume about 7,8 messages (out of 50) and again, it fails
> returning null. Then I tried out with NO_WAIT and this time, I was only
> able to consume first message. It fails returning nulls.
> 
> I tried this with CachingConnectionFactory / SingleConnectionFactory and
> also with direct ActiveMQ  ConnectionFactory. But the result is same. The
> application consumes several messages, and then starts to return null,
> while there are messages left in queue.
> 
> I am using Spring 2.5.5 with ActiveMQ 5.1.
> 
> Any suggestions are deeply appreciated.
> 
> Thanks
> 
> PS: I tried this with asynchronous message consumption using
> MessageListener and DefaultMessageListenerContainer, and it works as
> expected without this issue. 
> 

-- 
View this message in context: http://www.nabble.com/Spring-JmsTemplate-receive%28%29-returns-null-with-messages-in-Queue-tp18402053p19034200.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Spring JmsTemplate receive() returns null with messages in Queue

Posted by mkeenan <ke...@p2sol.com>.

James.Strachan wrote:
> 
> How many consumers do you have active? (See JMX). See these FAQ entries...
> 
> http://activemq.apache.org/i-do-not-receive-messages-in-my-second-consumer.html
> http://activemq.apache.org/what-is-the-prefetch-limit-for.html
> 

I am not the original poster, but I am having the same issue. I have tried
AMQ 5.1 and 5.2.  I am using Spring.NET with NMS (version 1.1 because it is
more thread safe). My prefetch is set to 1 but I have also tried 0 since I
am aiming for a "pull" model.

The behavior is unpredictable as far as how many messages are received by
the synchronous consumer before NULL is returned, but in almost every case
there are still messages left on the Queue.

I have turned on full logging at the broker, but I don't know quite what to
look for.  I'm not sure if NMS has any logging capability... I haven't
looked yet.

-- 
View this message in context: http://www.nabble.com/Spring-JmsTemplate-receive%28%29-returns-null-with-messages-in-Queue-tp18402053p20110439.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Spring JmsTemplate receive() returns null with messages in Queue

Posted by James Strachan <ja...@gmail.com>.
How many consumers do you have active? (See JMX). See these FAQ entries...

http://activemq.apache.org/i-do-not-receive-messages-in-my-second-consumer.html
http://activemq.apache.org/what-is-the-prefetch-limit-for.html


2008/7/11 Yohan Liyanage <yo...@gmail.com>:
>
> Hi,
>
> I tried to use JmsTemplate's receive() method for synchronous consumption of
> a Queue, but the method returns 'null', even when there are messages in the
> queue.
>
> The JmsTemplate (with a time out of two seconds) successfully receives first
> messages, but after a while, it is not able to consume messages from the
> queue, and returns null (timeout), even when there are messages in the Queue
> (I checked through JMX).
>
> Then I tried using RECEIVE_TIMEOUT_INDEFINITE_WAIT, and with that, I was
> able to consume about 7,8 messages (out of 50) and again, it fails returning
> null. Then I tried out with NO_WAIT and this time, I was only able to
> consume first message. It fails returning nulls.
>
> I tried this with CachingConnectionFactory / SingleConnectionFactory and
> also with direct ActiveMQ  ConnectionFactory. But the result is same. The
> application consumes several messages, and then starts to return null, while
> there are messages left in queue.
>
> I am using Spring 2.5.5 with ActiveMQ 5.1.
>
> Any suggestions are deeply appreciated.
>
> Thanks
>
> PS: I tried this with asynchronous message consumption using MessageListener
> and DefaultMessageListenerContainer, and it works as expected without this
> issue.
> --
> View this message in context: http://www.nabble.com/Spring-JmsTemplate-receive%28%29-returns-null-with-messages-in-Queue-tp18402053p18402053.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/