camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthew Zipay (JIRA)" <>
Subject [jira] [Commented] (CAMEL-10098) AbstractJdbcMessageIdRepository<T> is not actually parameterizable
Date Wed, 06 Jul 2016 14:47:11 GMT


Matthew Zipay commented on CAMEL-10098:

Yes, that could work.

The problem begins here in IdempotentConsumer:

        final String messageId;
        try {
            messageId = messageIdExpression.evaluate(exchange, String.class);

Changing {{messageId}} to Object and then casting to the parameterized type would be a start.

> AbstractJdbcMessageIdRepository<T> is not actually parameterizable
> ------------------------------------------------------------------
>                 Key: CAMEL-10098
>                 URL:
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core, camel-sql
>    Affects Versions: 2.15.1
>         Environment: Camel 2.15.1.redhat-620133
> JBoss Fuse 6.2.0.redhat-133
> openjdk version "1.8.0_45"
> OpenJDK Runtime Environment (build 1.8.0_45-b13)
> OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)
> Linux 3.10.0-229.1.2.el7.x86_64 #1 SMP Fri Mar 6 17:12:08 EST 2015 x86_64 GNU/Linux (RHEL
>            Reporter: Matthew Zipay
>            Priority: Minor
>             Fix For: Future
> The org.apache.camel.processor.idempotent.jdbc.AbstractJdbcMessageIdRepository class
is advertised as being extendable in the documentation, and is declared as parameterized in
the source code, so that developers "can extend to build custom JDBC idempotent repository."
> However, attempting to parameterize with anything other than String fails. The cause
appears to be org.apache.camel.processor.idempotent.IdempotentConsumer, whose process() method
assumes that the key is always a String before handing it off to the repository instance (which
may in fact be a AbstractJdbcMessageIdRepository<T> where T is *not* String). The results
is an unavoidable ClassCastException.
> Here is the relevant bit from a stack trace using {{public class IdempRepository extends
> {code}
> Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to my.custom.IdempKey
> 	at my.custom.IdempRepository.queryForInt([515:my-bundle:1.0.0.SNAPSHOT]
> 	at org.apache.camel.processor.idempotent.jdbc.AbstractJdbcMessageIdRepository$1.doInTransaction([273:org.apache.camel.camel-sql:2.15.1.redhat-620133]
> 	at org.apache.camel.processor.idempotent.jdbc.AbstractJdbcMessageIdRepository$1.doInTransaction([273:org.apache.camel.camel-sql:2.15.1.redhat-620133]
> 	at[202:org.apache.servicemix.bundles.spring-tx:3.2.12.RELEASE_1]
> 	at org.apache.camel.processor.idempotent.jdbc.AbstractJdbcMessageIdRepository.add([273:org.apache.camel.camel-sql:2.15.1.redhat-620133]
> 	at org.apache.camel.processor.idempotent.IdempotentConsumer.process([198:org.apache.camel.camel-core:2.15.1.redhat-620133]
> {code}

This message was sent by Atlassian JIRA

View raw message