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 suspected). The send method of the sender object should be enclosed in a synchronized block like synchronized(sender) { sender.send(message); } Yet, this is something that is not strictly required from the JMS specs (ckeck for example here: http://java.sun.com/javaee/5/docs/api/javax/jms/QueueSender.html): [...] 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 concurrently. 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: http://www.nabble.com/Messages-in-AMQ-are-randomly-not-sent--tf3572512s2354.html#a10011745 Sent from the ActiveMQ - User mailing list archive at Nabble.com.