greetings !

i am kind of newbie in camel, and cant solve one problem with the EIP of
idempotent consumer. I tried to configure a simple route to filter out
duplicate messages using MessageID header. With InmemoryMessageIdRepository
it works just fine, but then i created CAMEL_MESSAGEPROCESSED table in my DB
and tried to use JDBC based repo i am stuck, because i get one  error again
and again. 

at first sight it seems like  method *add(final String messageId)* from
*JdbcMessageIdRepository class*
(http://camel.apache.org/maven/current/camel-sql/apidocs/src-html/org/apache/camel/processor/idempotent/jdbc/JdbcMessageIdRepository.html)
simply does not replace ?,?,? mask with variables and as a result
INSERT_STRING contains ?  instead of values ...or problem with TIMESTAMP
type ... i dont know. :)  

Here is an error:

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback;
bad SQL grammar [*INSERT INTO CAMEL_MESSAGEPROCESSED (processorName,
messageId, createdAt) VALUES (?, ?, ?)*]; nested exception is
com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert an explicit
value into a timestamp column. Use INSERT with a column list to exclude the
timestamp column, or insert a DEFAULT into the timestamp column.
        at
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:98)[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:602)[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
...

Here is my camel-context.xml with primitive route, where only the first
message should be processed:

<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd";>

<bean id="messageIdDataSource"
class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
                <property name="driverClassName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
                <property name="url"
value="jdbc:sqlserver://localhost:1433;DatabaseName=camelTest" />
                <property name="username" value="camel" />
                <property name="password" value="Camel1234" />
                <property name="suppressClose" value="true" />
        </bean>
        
          <bean id="messageIdRepository"
class="org.apache.camel.processor.idempotent.jdbc.JdbcMessageIdRepository">
                <constructor-arg ref="messageIdDataSource" />
                <constructor-arg value="myProcessorName" />
        </bean>

  <camelContext xmlns="http://camel.apache.org/schema/spring";>
      <package>simpleRoute</package>
    <route>
 <from uri="timer://foo?fixedRate=true&amp;period=3000"/>
                <setHeader headerName="messageId">
        <constant>notUniqueId</constant>        
                </setHeader>
                <idempotentConsumer 
messageIdRepositoryRef="messageIdRepository">
                        <header>messageId</header>
                        <to uri="seda:audit" />
                </idempotentConsumer>           
                </route>
  </camelContext>


Route "from seda:audit" implemented in java DSL:

 from("seda:audit")
                 .process(new Processor() {
                    public void process(Exchange exchange) throws Exception {  
                        
                        System.out.println("Message processed !");
                    }
                    });


Simple as it can be, but doesn't work :(

Any suggestions, why my repository can't insert ID's in DB. 

PS SQL Server use is inevitable (project term)
 

--
View this message in context: 
http://camel.465427.n5.nabble.com/JDBC-based-idempotent-repository-problem-tp4980094p4980094.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to