activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luciano Mollea <>
Subject Messages in AMQ are randomly not sent?
Date Fri, 13 Apr 2007 16:10:36 GMT

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.

We're using ActiveMQ 4.1.0 as a standalone process, with AMQ 4.0.2 libraries
on the client side. This problem has been verified also with 4.1.0

Our usage scenario is as follows:
Messages are sent on a single queue; the messages represents requests for
which a response is expected; there is a timeout for the response; replies
are waited on a temp-queue. The temp queue is created when the
connection/session is started the first time; on the temp queue messages are
consumed via a single MessageListener.
When the client sends a request, it associates to the JMS Message:
- a correlation ID (created via a string representing the client name+a
sequence number <-- this id is created in a synchronized method)
- the JMSReplyTo setting it to the temp queue.
The client then insert (synchronizing on the map) the request into an
hashmap<String, message>, the String key is the correlation id.
The client then synchronizes on the message and sends the message [*] then
waits for the reply for a configured timeout.

When the message listener receives a message from the temp queue, extracts
the correlation ID (left unchanged by the server) from the message received
and looks up in the map the pending request, if it finds that, it changes
the message in the association <correlationid, message> with the reply
message and then issues a notify on the request message, thus waking up the
waiting client. If the Message Listener does not find anything in the
pending map for the correlation id, it simply discard the message.

The client, when woken up (from a notify of from a wait timeout), removes
(synchronizedly) from the map the object associated with the correlation id.
If it's the same message he put before the send, then it is a timeout (no
response has arrived) and returns with an error, otherwise it extracts the
response from the message received and returns the result.

We have used this mechanism some time, but only now when the number of
requests have increased significantly (300k / hour) as the number of
concurrent threads sending messages (30-40) we are experiencing a 3-4%
message loss (timeouts).

We noticed that the consumer of the request queue does not receive the
messages that go time-out. I mean: if I send 5000 messages and get 4
timeouts, i will see that the consumer on the request queue gets only 4996

Any idea about the reason of this problem?

[*] 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
View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message