Hi,

Below is from IdempotentConsumer.java 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.
-- 
View this message in context: 
http://www.nabble.com/Problem-with-IdempotentConsumer-tp22467720p22467720.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to