activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chasta <>
Subject Re: Dynamic topics, in-VM: MessageListener not being invoked
Date Sun, 05 Nov 2006 17:06:26 GMT

Chasta wrote:
> Hi,
> I have a problem; I've been banging my head against this for quite some
> time now so any advice would be much appreciated. I've searched the
> archives and the docs but didn't find a solution.
> I'm using ActiveMQ in a Spring-based application, but w/o Spring's
> specific JMS features (e.g., I'm not using JmsTemplate, etc). Using an
> embedded broker, the in-VM transport and (only) pub/sub, synchronous
> message consuming works fine but asynchronous consumption (using a message
> listener which is set to the consumer) does not work – the MessageListener
> just never gets called.
> By the way, what I really need is for each thread to consume its messages
> synchronously, but from a single channel, to which all messages in all
> topics that particular thread is subscribed to will arrive. Since I didn't
> see a simpler way for JMS to allow this (and quite possibly I've missed
> something...), I implemented this by each thread having a blocking
> concurrent queue to which its message listener (same thread-safe instance
> for all consumers of a given thread) enqueues the messages' payload.
> My application is moderately parallelized; there will be ~20 modules, each
> running in its own thread. Currently they are running in the same VM, but
> the future will demand involving several hosts. The plan is for all of the
> threads to communicate transparently via JMS, not knowing if the
> recipients share the VM with them or not.
> Another, related question: The topics are created dynamically. Is there
> any problem with 2 (or more) threads calling 'createTopic' on the same
> topic (same topic name) ? (One publisher and one subscriber, at the
> least). Or should I share the same Topic object between the threads, when
> they're in the same VM?
> Thanks,
> Chasta

Hi again,
just wanted to let you know the main problem (the MessageListener not being
invoked) is solved; it was a threading issue (incorrect usage of the Session
object with regard to its thread-safety). Sorry to bug you about that.

Anyway, I'd still appreciate answers for my other questions:
1. Should/must I share Topic objects between the different threads in the
same VM? (I'm asking this because before I did share the object references,
I did once get an exception from ActiveMQ telling me the Topic object was
already created. I'm not using JNDI. I didn't see any specification about
thread-safety of the Topic object in the JMS/ActiveMQ docs.)
2. Isn't there a better way (e.g. not by using a private concurrent queue)
to receive all messages synchronously from a single source? (E.g. one
receive() call will block till any message is available in one of the topics
the client is subscribed to).

Thanks again,
View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message