You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by ashish <as...@gmail.com> on 2011/07/21 18:28:31 UTC

Point-to-Point Model - Multiple Consumers - ActiveMQ - 5.3.2

Hi,

I have the following scenario where multiple consumers poll the same queue
to retrieve messages in a point to point model. The acknowledgment mode
being used is: Individual_Acknowledge

My requirement is that the message should be processed only once.

 From what I understand:  If a consumer has retrieved a message which has
not been acknowledged yet then the other consumers will not be to retrieve
this message till the session of the first consumer is closed. 
*
Is my understanding correct? *

I ran a couple of threads which retrieve messages from the queue (the queue
has only one message). Both threads do not acknowledge the message. The
first thread runs every 60 sec while the second thread runs every 20
sec.Each thread creates a separate connection to ActiveMQ. Each thread tries
to retrieve the messages before it sleeps and disconnects the session after
it finishes sleeping.

Following is the output of this program. The first thread retrieves the
message first.While it is holding the session, the second thread does not
retrieve a message but when the first thread releases the connection, none
of the threads immediately pick up the message again. It is a while before a
thread picks up the message. 

*I wanted to know as to why this is happening?*


FIRST - NUMBER OF MESSAGES RETRIEVED: 1
SECOND - NO MESSAGES RETRIEVED
SECOND - CLOSED CONNECTION
SECOND - NO MESSAGES RETRIEVED
SECOND - CLOSED CONNECTION
SECOND - NO MESSAGES RETRIEVED
*FIRST - CLOSED CONNECTION
FIRST - NO MESSAGES RETRIEVED
SECOND - CLOSED CONNECTION
SECOND - NO MESSAGES RETRIEVED
SECOND - CLOSED CONNECTION
SECOND - NO MESSAGES RETRIEVED
SECOND - CLOSED CONNECTION*
SECOND - NUMBER OF MESSAGES RETRIEVED: 1
FIRST - CLOSED CONNECTION
FIRST - NO MESSAGES RETRIEVED
SECOND - CLOSED CONNECTION
SECOND - NO MESSAGES RETRIEVED
SECOND - CLOSED CONNECTION
SECOND - NO MESSAGES RETRIEVED



-Ashish
















-Ashish

--
View this message in context: http://activemq.2283324.n4.nabble.com/Point-to-Point-Model-Multiple-Consumers-ActiveMQ-5-3-2-tp3684188p3684188.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Point-to-Point Model - Multiple Consumers - ActiveMQ - 5.3.2

Posted by yousafsajjad <mu...@dell.com>.
Broker push messages to the consumer in a roundrobin fashion. So I believe if
you run your program a little longer you would be able to see the pattern.
You can avoid it by setting prefetch limit = 1. This is enable consumers to
poll for messages from the queue.

Also it would better if you use pooledconnection instead of establishing
connection every single time.

--
View this message in context: http://activemq.2283324.n4.nabble.com/Point-to-Point-Model-Multiple-Consumers-ActiveMQ-5-3-2-tp3684188p3694567.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.