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 <davidkarl...@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

Reply via email to