activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nlif <naa...@dbnet.co.il>
Subject Consuming a group of messages in a single transaction
Date Wed, 19 Jul 2006 15:04:36 GMT

Hi,

I am using ActiveMQ's MessageGroups feature in order to send and receive
several related messages as a single unit-of-work. I am using a transacted
producer, so all messages are sent atomically, but I don't know how to
implement the consumer. The way I see it - the consumer should accumulate
the messages until it has all of them and then construct the aggregate, save
it and only then - acknowledge them.

Just to clarfiy, the problem I am trying to solve is that of the consumer
crashing after acknowleding some, but not all, of the messages in the group.
This will result in loss of messages.

So I started-off with a MessageListener configured with Jencks, for pooling.
The MessageListener should collect all messages in the group, and once it
has all of them - it should acknowledge all of the together. Now, ensuring
all messages are indeed delivered to the same MessageListener is taken care
of by the MessageGroups feature.  But since Jencks commits the transaction
when the onMessage() method returns - this prevents me from acknowledging
all messages together. 

I know some people throw a RuntimeException in the onMessage() method in
order to make Jencks rollback, but that's awkward to say the least, since it
will cause messages I already have to be redlivered again and again!
Furthermore, if I am not mistaken, although all Jencks' threads share the
same MessageListener instance, each message is (or may be) delivered by a
different session. This means, that even if I did find a way to commit the
transaction myself - it would still not achieve the behavior I need.

Is there any way to consume several messages in a single transaction, while
using an async consumer and Jencks? Or is there another way, and I am simply
approaching the whole thing in the wrong way?

I'd appreciate any tips.

Thanks,
Naaman
-- 
View this message in context: http://www.nabble.com/Consuming-a-group-of-messages-in-a-single-transaction-tf1966918.html#a5397996
Sent from the ActiveMQ - User forum at Nabble.com.


Mime
View raw message