activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From artnaseef <...@artnaseef.com>
Subject Re: is msg.acknowledge thread safe in INDIVIDUAL_ACKNOWLEDGE mode?
Date Wed, 05 Mar 2014 16:24:59 GMT
That sounds right to me. As long as each message object is not simultaneously used in more
than one thread, you should be safe. 

Sent from my iPhone

> On Mar 5, 2014, at 3:10 AM, "Li Li [via ActiveMQ]" <ml-node+s2283324n4678545h43@n4.nabble.com>
wrote:
> 
> hi all, 
>     I want to use INDIVIDUAL_ACKNOWLEDGE like this: 
> I have one session and a receiver thread. this thread receive messages 
> to ten worker thread. 
> each worker thread acknowledge it's message 
> 
> receiver thread: 
> while(true){ 
>       Message msg=receiver.receive(); 
>       put msg to a ConcurrentLinkedList; 
> } 
> 
> Worker thread: 
> while(true){ 
>      Message msg=getMessgeFromLinkedList(); 
>      process msg; 
>      msg.acknowledge(); 
> } 
> 
> is it thread safe? 
> 
> I have debugged into ActiveMQMessageConsumer.acknowledge in 5.9.0 
> 
>     void acknowledge(MessageDispatch md, byte ackType) throws JMSException { 
>         MessageAck ack = new MessageAck(md, ackType, 1); 
>         session.sendAck(ack); 
>         synchronized(deliveredMessages){ 
>             deliveredMessages.remove(md); 
>         } 
>     } 
> 
> 1. it seems remove message from deliveredMessages is synchronized 
> 2. session.sendAck(ack); 
>        sendAck(ack,false); 
>            asyncSendPacket(ack); 
>                 connection.asyncSendPacket(command); 
> connection is thread safe, so message.acknowledge is thread-safe? 
> 
> 
> If you reply to this email, your message will be added to the discussion below:
> http://activemq.2283324.n4.nabble.com/is-msg-acknowledge-thread-safe-in-INDIVIDUAL-ACKNOWLEDGE-mode-tp4678545.html
> To start a new topic under ActiveMQ - Dev, email ml-node+s2283324n2368404h72@n4.nabble.com

> To unsubscribe from ActiveMQ - Dev, click here.
> NAML




--
View this message in context: http://activemq.2283324.n4.nabble.com/is-msg-acknowledge-thread-safe-in-INDIVIDUAL-ACKNOWLEDGE-mode-tp4678545p4678553.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message