activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From itamara <>
Subject Maintaining Message Uniqueness in a Queue
Date Tue, 29 Sep 2009 10:26:33 GMT

hi AMQ users

What is the best way to ensure Message Uniqueness in a Queue?

I'm having the following architecture:

A single Scheduler (a quartz scheduled job) is periodically checking a DB
for entities to update, for each entity-to-update it uses a single Sender to
send an Update Message with a property holding the entity ID.

The Sender references an ActiveMQQueue destination and a Spring's
JmsTemplate over a PooledConnectionFactory.

The Consumers - MessageListeners in a Spring's
DefaultMessageListenerContainer container - receive a message and do their
onMessage, which may involves updating the DB.

I wish to avoid more then one Consumer updating the same entity
simultaneously, as it will result in DB errors.

I thought the Scheduler should account for this synchronization, so upon
resolution of the entities to update, it tags them in order to know not to
update them again - a tag that is removed when update is finished. But as
errors may occur, this tag is taken in account only for a certain period of
time. This makes the situation, in which the queue contains two messages
with the same entity ID, possible.

Which may cause exactly what I'm trying to avoid.

How do I pull it off?

I thought knowing which messages are currently in the queue could help the
Scheduler decide.

What about the message ID? Can it help here?

I could also expire the message, but it is not accurate. I might throw away
messages for no good reason.

Maybe it is better to do this synchronization elsewhere?

Thanks a lot for any help or thoughts.
View this message in context:
Sent from the ActiveMQ - User mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message