On 12/13/2013 03:29 AM, zielin wrote:
Hello,
I'm writing library in QT C++ which wraps ActiveMQ CMS API and allows using
activemq without including any cms api headers etc. I have written
synchronous consumer and producer. Everything works fine until I create two
synchronous consumers consuming messages in separate threads. For example:
Consumer c1;
c1.topic = "test";
c1.start(); -- starts thread 1
c1.sleep(2);
Consumer c2;
c2.topic = "test2";
c2.start(); -- starts thread 2
Code above should create two consumers working separately in threads, but in
the end, works only c2, and it can consume messages. Consumer c1 is totally
suspended and never exits from cms::MessageConsumer::receive method.
Consumers are created in threads, they doesn't share sessions. I haven't
implemented consumers as messagelisteners because I wanted to avoid
including ActiveMQ header files in my declaration file. I want to create
fully functional library for QT which allows using activemq. It works fine
for one consumer :/.
Can You help me solve problem of locked first consumer? Is there possibility
using synchronous consumers in separated threads independently ?
Thanks.
--
View this message in context:
http://activemq.2283324.n4.nabble.com/ActiveMQ-sync-consumers-in-threads-tp4675514.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
There's no known issue with using two consumers that I'm aware of. I'd
take a look at your QT code and ensure you don't have and issue there
first, or get back to basics and try implementing the CMS code to do
what you want first and then abstract it to the QT library you are
writing. One thing to be aware of is consumer prefetch, is one consumer
is hogging all the messages in its prefetch buffer your second one
wouldn't be able to receive anything until enough messages are produced.
--
Tim Bish
Sr Software Engineer | RedHat Inc.
[email protected] | www.fusesource.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/