Search code examples
apache-camelactivemq-classicapache-servicemixeip

How to send the original message to DLQ after processing


How can I customize the route so that the original message appears in dlq? Now if my server is unavailable, messages appear in dlq after processing, for example: the message with body “origin_message” is in the my_test queue, after processing in myProcess I change it to “new_message”, and if the server is unavailable or answered with codes 400+ 500+ , in my queue my_dlq there is a message with the body "new_message"

<bean id="myDeadLetterErrorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder">
        <property name="deadLetterUri" value="activemq://my_dlq"/>
</bean>

<bean id="myProcess" class="mapper.MyProcess" />    

    <camelContext xmlns="http://camel.apache.org/schema/blueprint">

      <route errorHandlerRef="myDeadLetterErrorHandler">
        <from uri="activemq://my_test"/>
        <process ref="myProcess" />
        <to uri="http://localhost:3000"/>
      </route>

    </camelContext>

Solution

  • You can configure the useOriginalMessage=true on the error handler.