You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by fungrim <co...@larsan.net> on 2007/05/25 12:47:40 UTC

Message acknowledgement synchronization problem

Hello, I'm not entirely sure of what the JMS spec. says about this, so I'm
posting this as a question rather than a bug. We have a system with
asynchronous message "execution" taking messages of an ActiveMQ queue with
message groups enabled. It turns out that the code for ack'ing separate
messages uses a bit of unsafe code in their (shared) session. We're using
ActiveMQ 4.1.0. This stack trace explains the problem:

>>>
Caused by: java.lang.NullPointerException
   at org.apache.activemq.command.MessageAck.<init>(MessageAck.java:66)
   at
org.apache.activemq.ActiveMQMessageConsumer.acknowledge(ActiveMQMessageConsumer.java:747)
   at
org.apache.activemq.ActiveMQSession.acknowledge(ActiveMQSession.java:1381)
   at
org.apache.activemq.ActiveMQMessageConsumer$1.execute(ActiveMQMessageConsumer.java:444)
   at
org.apache.activemq.command.ActiveMQMessage.acknowledge(ActiveMQMessage.java:95) 
>>>

(Ie. the ActiveMQMessageConsumer is not thread safe)

So the question is, is this the correct behaviour? I can obviously force a
synchronization on the session object on my end, but that seems like a
somewhat ugly sollution.

Regards
/Lars J. Nilsson
-- 
View this message in context: http://www.nabble.com/Message-acknowledgement-synchronization-problem-tf3815389s2354.html#a10800690
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Message acknowledgement synchronization problem

Posted by fungrim <co...@larsan.net>.

James.Strachan wrote:
> 
> A JMS Session, Consumer & Producer is only meant to be used by one
> thread at any point in time. Thats the reason we don't sync ourselves
> (it just adds overhead when the spec is pretty clear about thread
> usage).
> 

Hi James, thank you for the quick response. And thank you for the very kind
RTFM :-) I did know the session was to be used be one thread at the time.
However, I didn't associate it with message acknowledgement, especially not
when messages can be delivered asynchronously anyway. Ah well, back to the
drawing board for me.

Regards
/Lars
-- 
View this message in context: http://www.nabble.com/Message-acknowledgement-synchronization-problem-tf3815389s2354.html#a10804224
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Message acknowledgement synchronization problem

Posted by James Strachan <ja...@gmail.com>.
A JMS Session, Consumer & Producer is only meant to be used by one
thread at any point in time. Thats the reason we don't sync ourselves
(it just adds overhead when the spec is pretty clear about thread
usage).


On 5/25/07, fungrim <co...@larsan.net> wrote:
>
> Hello, I'm not entirely sure of what the JMS spec. says about this, so I'm
> posting this as a question rather than a bug. We have a system with
> asynchronous message "execution" taking messages of an ActiveMQ queue with
> message groups enabled. It turns out that the code for ack'ing separate
> messages uses a bit of unsafe code in their (shared) session. We're using
> ActiveMQ 4.1.0. This stack trace explains the problem:
>
> >>>
> Caused by: java.lang.NullPointerException
>    at org.apache.activemq.command.MessageAck.<init>(MessageAck.java:66)
>    at
> org.apache.activemq.ActiveMQMessageConsumer.acknowledge(ActiveMQMessageConsumer.java:747)
>    at
> org.apache.activemq.ActiveMQSession.acknowledge(ActiveMQSession.java:1381)
>    at
> org.apache.activemq.ActiveMQMessageConsumer$1.execute(ActiveMQMessageConsumer.java:444)
>    at
> org.apache.activemq.command.ActiveMQMessage.acknowledge(ActiveMQMessage.java:95)
> >>>
>
> (Ie. the ActiveMQMessageConsumer is not thread safe)
>
> So the question is, is this the correct behaviour? I can obviously force a
> synchronization on the session object on my end, but that seems like a
> somewhat ugly sollution.
>
> Regards
> /Lars J. Nilsson
> --
> View this message in context: http://www.nabble.com/Message-acknowledgement-synchronization-problem-tf3815389s2354.html#a10800690
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


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