activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Gellings (JIRA)" <>
Subject [jira] Updated: (AMQNET-243) failover causes duplicate messages
Date Wed, 14 Apr 2010 19:11:44 GMT


Mark Gellings updated AMQNET-243:


Attached is sample code on how we implemented an Idempotent Consumer pattern on top of NMS.

Basic execution logic goes like this...the IdempotentListener<TMessage> Prehook( ) method
is called before a message is processed.  If it is the original message (redelivered counter
0) then we check to see if the message is in the database, if it is we send it through as
redelivered (by throwing our RecoverableMessageException) so the listener logic can process
as a redelivery.


--When coding this I tried to follow the Idempotent Consumer pattern in Apache Camel.
--I understand some of this code may not make sense (e.g. extension methods, it's a layer
of abstraction above ActiveMQ.NMS, some code is missing).  Unfortunately I can't submit that
--While it may make sense to have a Camel.Net sub project, it may be overkill as I don't see
other EIP being implemented.  If adding this logic to NMS, the database connection needs to
remain agnostic.  As you can see we used iBATIS.NET to connect to the database, so theoretically
any database platform could be used.  But ultimately we wouldn't want ActiveMQ.NMS to have
iBATIS dependencies.  Perhaps an IMessageDao implementation would be required and set on initialization
to enable an Idempotent Consumer.  Then NMS is not responsible for the implementation of the
database access.

All else aside, attached is an example of how to code it.

> failover causes duplicate messages
> ----------------------------------
>                 Key: AMQNET-243
>                 URL:
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>          Components: NMS
>    Affects Versions: 1.1.0
>            Reporter: Mark Gellings
>            Assignee: Jim Gomes
>         Attachments:
> Reference for specifics on problem.
> Attached to that issue is a zip file which is password protected with password "fridaytest".
> We're using ActiveMQ v5.2, jdbc master/slave MSSQL 2008. Attached is an NMS v1.2 RC4
consumer with a transacted session as well as activemq.xml.
> To replicate:
> 1) Work through the console prompts and produce 50 msgs.
> 2) Restart console and start consuming those 50 msgs.
> 3) In the middle of the consumer processing, restart broker
> 4) The last message consumer was processing will be resent and not marked as redelivered.
(this is the idempotent msg problem. Ex. - instead of $500 getting deposited into your account,
$1000 does)
> 5) Then NMS blows up which seems like a different problem?
> From what I understand this shouldn't be the case if you use a transacted session, however
the attached console app can prove it is a problem.
> Bottomline--I thought this was why the camel idempotent consumer pattern [1] existed
which can be leveraged by java clients.
> [1]
> Regards,
> Mark

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


View raw message