camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Problem with IdempotentConsumer
Date Thu, 12 Mar 2009 04:42:42 GMT
On Thu, Mar 12, 2009 at 1:44 AM, chrajanirao <> wrote:
> Hi,
> Below is from of Camel 1.5:
> public void process(Exchange exchange) throws Exception {
>        String messageId =
> ExpressionHelper.evaluateAsString(messageIdExpression, exchange);
>        if (messageId == null) {
>            throw new NoMessageIdException(exchange, messageIdExpression);
>        }
>        if (!messageIdRepository.contains(messageId)) {
>            nextProcessor.process(exchange);
>        } else {
>            onDuplicateMessage(exchange, messageId);
>        }
>    }
> The messageIdRepository.contains method is checking as well as adding the
> messageId to repository if it doesn't exist already. I see this as a problem
> because, before even processing message we are adding it to the repository,
> how do we know if the process was successful or not? I mean in case of
> failure to the process we would like to re-process the message when its
> delivered again but since the repository already contains the messageId, how
> do to determine whether to process it or not?
> Wouldn't it be better to have "contains" and "addToRepository" as separate
> operations and call addToRepository after nextProcessor.process. Another
> option would be to mark initially as "Received" and after process as
> "Processed".
> Hope to get a reply/opinion from someone.
Well spotted. In fact in Camel 2.0 we have refactored the code a bit
so there is a SPI interface IdempotentRepository
that supports add and contains operations.

And the approach you suggest wtih adding on completion is in fact how
the file component in Camel 2.0 works.
It has build in support for idempotent, to avoid consuming the same
file again, in case you have turned this feature on.

So the processor itself was an oversight that we didnt fix it also. So
I will create a ticket and fix the IdempotentConsumer in Camel 2.0.

> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
Apache Camel Committer

Open Source Integration:

View raw message