activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Strachan <>
Subject Re: Maintaining Message Uniqueness in a Queue
Date Tue, 29 Sep 2009 11:30:01 GMT
2009/9/29 itamara <>:
> 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.

Using Message Groups to ensure only one consumer thread processes a
certain entity at once sounds like a simple solution...

> 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?

Message IDs are unique and set after you send them


Open Source Integration

View raw message