You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by David Karlsen <da...@gmail.com> on 2014/05/22 21:12:00 UTC

Idempotent inconsistencies

IdempotentConsumer demands that the messageId is a string:

final String messageId = messageIdExpression.evaluate(exchange,
String.class);
        if (messageId == null) {
            throw new NoMessageIdException(exchange, messageIdExpression);
        }

        boolean newKey;
        if (eager) {
            // add the key to the repository
            newKey = idempotentRepository.add(messageId);
        } else {
            // check if we already have the key
            newKey = !idempotentRepository.contains(messageId);
        }

(Why isn't it an object or a parameterized type?)

but the IdempotentRepository interface is parameterized to hold any type <E>


-- 
--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen

Re: Idempotent inconsistencies

Posted by David Karlsen <da...@gmail.com>.
Done: https://issues.apache.org/jira/browse/CAMEL-7461



2014-05-23 8:48 GMT+02:00 Claus Ibsen <cl...@gmail.com>:

> Hi
>
> I think its historical reasons with using strings first in Camel.
>
> You are welcome to log a ticket to get this improved in a future release
>
> On Thu, May 22, 2014 at 9:12 PM, David Karlsen <da...@gmail.com>
> wrote:
> > IdempotentConsumer demands that the messageId is a string:
> >
> > final String messageId = messageIdExpression.evaluate(exchange,
> > String.class);
> >         if (messageId == null) {
> >             throw new NoMessageIdException(exchange,
> messageIdExpression);
> >         }
> >
> >         boolean newKey;
> >         if (eager) {
> >             // add the key to the repository
> >             newKey = idempotentRepository.add(messageId);
> >         } else {
> >             // check if we already have the key
> >             newKey = !idempotentRepository.contains(messageId);
> >         }
> >
> > (Why isn't it an object or a parameterized type?)
> >
> > but the IdempotentRepository interface is parameterized to hold any type
> <E>
> >
> >
> > --
> > --
> > David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>



-- 
--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen

Re: Idempotent inconsistencies

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I think its historical reasons with using strings first in Camel.

You are welcome to log a ticket to get this improved in a future release

On Thu, May 22, 2014 at 9:12 PM, David Karlsen <da...@gmail.com> wrote:
> IdempotentConsumer demands that the messageId is a string:
>
> final String messageId = messageIdExpression.evaluate(exchange,
> String.class);
>         if (messageId == null) {
>             throw new NoMessageIdException(exchange, messageIdExpression);
>         }
>
>         boolean newKey;
>         if (eager) {
>             // add the key to the repository
>             newKey = idempotentRepository.add(messageId);
>         } else {
>             // check if we already have the key
>             newKey = !idempotentRepository.contains(messageId);
>         }
>
> (Why isn't it an object or a parameterized type?)
>
> but the IdempotentRepository interface is parameterized to hold any type <E>
>
>
> --
> --
> David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Idempotent inconsistencies

Posted by Charles Moulliard <ch...@gmail.com>.
You are right. The type define in the interface is <E> but unfortunately in
the code, we are using <String> as type

1) constructor of idempotentconsumer defines the type as String

    public IdempotentConsumer(Expression messageIdExpression,
IdempotentRepository<String> idempotentRepository,
                              boolean eager, boolean skipDuplicate, boolean
removeOnFailure, Processor processor) {

2) like also the createProcessor of the idempotentConsumerDefinition

   @Override
    @SuppressWarnings("unchecked")
    public Processor createProcessor(RouteContext routeContext) throws
Exception {
        Processor childProcessor = this.createChildProcessor(routeContext,
true);

        IdempotentRepository<String> idempotentRepository =
                (IdempotentRepository<String>)
resolveMessageIdRepository(routeContext);
        ObjectHelper.notNull(idempotentRepository, "idempotentRepository",
this);


On Thu, May 22, 2014 at 9:12 PM, David Karlsen <da...@gmail.com>wrote:

> IdempotentConsumer demands that the messageId is a string:
>
> final String messageId = messageIdExpression.evaluate(exchange,
> String.class);
>         if (messageId == null) {
>             throw new NoMessageIdException(exchange, messageIdExpression);
>         }
>
>         boolean newKey;
>         if (eager) {
>             // add the key to the repository
>             newKey = idempotentRepository.add(messageId);
>         } else {
>             // check if we already have the key
>             newKey = !idempotentRepository.contains(messageId);
>         }
>
> (Why isn't it an object or a parameterized type?)
>
> but the IdempotentRepository interface is parameterized to hold any type
> <E>
>
>
> --
> --
> David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io