You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by manua <ag...@gmail.com> on 2011/11/22 16:19:09 UTC

ActiveMQ CPP : Same message being consumed by two consumers

HI,

We have used activemq cpp and created a session. The session is set in the
auto acknowledge mode.
Multiple threads have been launched from that code and each thread has a
consumer.All consumers are listening on the same queue, and sharing the same
session.

It looks that a message on that queue is being consumed by more than
consumer.
Is it possible that same message is consumed by more than one consumer when
the session is set in auto acknowledge mode, or am I doing something wrong.

Kindly let me know your inputs.

Thanks,
Manu

--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-CPP-Same-message-being-consumed-by-two-consumers-tp4096080p4096080.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: ActiveMQ CPP : Same message being consumed by two consumers

Posted by manua <ag...@gmail.com>.
Thanks Ivan,

That helps.
I will create one consumer per session.

Just to add to your argument, following link also suggests, what you have
suggested,

http://activemq.apache.org/multiple-consumers-on-a-queue.html

Thanks,
Manu

--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-CPP-Same-message-being-consumed-by-two-consumers-tp4096080p4097105.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: ActiveMQ CPP : Same message being consumed by two consumers

Posted by Ivan Pechorin <iv...@gmail.com>.
2011/11/22 manua <ag...@gmail.com>:

> Each consumer is running in a different thread, though listening on the same
> queue.
> We dont see any concurrent access.

Consumers always belong to some session; session is thread-specific
(this is a generic principle of JMS, and as far as I know it's valid
both for ActiveMQ-C++ and for Java).

Therefore, you can't just create two consumers from the same session
and use them concurrently from different threads, because that would
effectively mean concurrent access to the session that owns these
consumers.

Re: ActiveMQ CPP : Same message being consumed by two consumers

Posted by manua <ag...@gmail.com>.
Ivan,

Each consumer is running in a different thread, though listening on the same
queue.
We dont see any concurrent access.

Thanks
Manu

--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-CPP-Same-message-being-consumed-by-two-consumers-tp4096080p4096622.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: ActiveMQ CPP : Same message being consumed by two consumers

Posted by Ivan Pechorin <iv...@gmail.com>.
2011/11/22 manua <ag...@gmail.com>:
>
> We have used activemq cpp and created a session. The session is set in the
> auto acknowledge mode.
> Multiple threads have been launched from that code and each thread has a
> consumer.All consumers are listening on the same queue, and sharing the same
> session.

Do you protect the session properly from concurrent access by multiple
threads (i.e. using mutex)?

Re: ActiveMQ CPP : Same message being consumed by two consumers

Posted by manua <ag...@gmail.com>.
Thanks Tim,

We  dont have a simple test case for this.
We will further investigate the issue in light of your inputs.

Thanks
Manu

--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-CPP-Same-message-being-consumed-by-two-consumers-tp4096080p4096611.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: ActiveMQ CPP : Same message being consumed by two consumers

Posted by Timothy Bish <ta...@gmail.com>.
On Tue, 2011-11-22 at 07:19 -0800, manua wrote:
> HI,
> 
> We have used activemq cpp and created a session. The session is set in the
> auto acknowledge mode.
> Multiple threads have been launched from that code and each thread has a
> consumer.All consumers are listening on the same queue, and sharing the same
> session.
> 
> It looks that a message on that queue is being consumed by more than
> consumer.
> Is it possible that same message is consumed by more than one consumer when
> the session is set in auto acknowledge mode, or am I doing something wrong.
> 
> Kindly let me know your inputs.
> 
> Thanks,
> Manu

This shouldn't happen.  There can be a duplicate message in the case of
failover because the CPP client doesn't have the Message Audit facility
that the Java client does.  Do you have a test case that can reproduce
the problem?

Regards

-- 
Tim Bish
------------
FuseSource
Email: tim.bish@fusesource.com
Web: http://fusesource.com
Twitter: tabish121
Blog: http://timbish.blogspot.com/