activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luciano Mollea <>
Subject Re: Messages in AMQ are randomly not sent?
Date Mon, 16 Apr 2007 07:56:48 GMT

Luciano Mollea wrote:
> Hi all.
> We're experiencing a strange situation here. It seems that randomly AMQ
> does not send a message, this happens depending on the load, this problem
> seems to happen more frequently as more threads concurrently send messages
> on the same queue.
> [...]
> [*] a thought about this: the send is not synchronized on the sender
> object (that is used multi-threaded) but on the sent message.. could this
> be the cause?

I reply myself as it seems we found the solution (and it is as we
The send method of the sender object should be enclosed in a synchronized
block like

synchronized(sender) {

Yet, this is something that is not strictly required from the JMS specs
(ckeck for example here:

[...] During the execution of its send method, a message must not be changed
by other threads within the client. If the message is modified, the result
of the send is undefined.[...]

It requires that the message be immutable for the send operation, it does
not strictly requires that only one send can be done at a time. To be
honest, it doesn't specify either that multiple sends may be done
I't some sort of "grey area" in the specs that may change from
implementation to implementation.
I'm not filing it as a bug, but I'd suggest that the send operations should
be made thread safe. If someone switches from an thread-safe implementation
of another JMS broker to ActiveMQ, he may consider ActiveMQ as "broken".
I think that it could be done by simply adding a synchronized declaration on
all the "send" (and maybe the "publish" of the TopicPublisher) methods.

Thanks the same, even to those that replied off-list.
View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message