Idempotent don't filter within onexception

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Idempotent don't filter within onexception

Charles Moulliard-2
Hi,

I have created this Apache Camel Route to report an exception one time
(using the direct:notify endpoint) but the info is logged x times as the
maxredelivery policy defined on the JMS Client with ActiveMQ is equal to 2

    <broker brokerName="demo" xmlns="http://activemq.apache.org/schema/core
">
        <destinationPolicy>
            <policyMap>
                <policyEntries>
                    <policyEntry queue=">">
                        <deadLetterStrategy>
                            <individualDeadLetterStrategy
queuePrefix="DLQ." useQueueForQueueMessages="true"/>
                        </deadLetterStrategy>
                    </policyEntry>
                </policyEntries>
            </policyMap>
        </destinationPolicy>
        <transportConnectors>
            <transportConnector name="tcp" uri="tcp://localhost:61618"/>
        </transportConnectors>
    </broker>

    <bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
        <property name="connectionFactory" ref="jmsConnectionFactory"/>
    </bean>

    <bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://localhost:61618"/>
        <property name="redeliveryPolicy" ref="redeliveryPolicy"/>
    </bean>

    <amq:redeliveryPolicy id="redeliveryPolicy" maximumRedeliveries="2"
initialRedeliveryDelay="500"/>

    <bean id="amq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="jmsConnectionFactory"/>
        <property name="transactionManager" ref="jmsTransactionManager"/>
        <property name="transacted" value="true"/>
    </bean>

        <route>
            <!-- Consume files from jms queue using a Spring Tx JMS Client
-->
            <from uri="amq:{{queueInput}}"/>
            <onException>
                <exception>java.lang.IllegalArgumentException</exception>
                <log message=">> Error took place. Message will bemoved to
DLQ"/>
                <setHeader headerName="error-code">
                    <constant>111</constant>
                </setHeader>
                <setHeader headerName="error-message">
                    <simple>${exception.message}</simple>
                </setHeader>
                <idempotentConsumer messageIdRepositoryRef="memoryRepo">
                    <header>error-code</header>
                    <to uri="direct:notify"/>
                </idempotentConsumer>
            </onException>
            <split>
                <tokenize token="\n"/>
                <to ref="csv2json"/>
                <to uri="amq:{{queueOutput}}"/>
            </split>
        </route>

        <route>
            <from uri="direct:notify"/>
             <!-- CALLED 3 TIMES -->
            <log message=">> Error code : ${header.error-code}, Error
Message : ${header.error-message}"/>
        </route>

Why the idempotentConsumer doesn't filter exception error-code  ?

Regards,

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