Camel message body becomes null when sent to error queue in onException() method.

Solution In Progress - Updated -

Issue

I have following camel route:

String destination = "cxf:http://localhost:9090/test?dataFormat=MESSAGE";

    from("jms:queue:dslSource")
        .onException(java.net.ConnectException.class, Exception.class)
            .maximumRedeliveries(3)
            .maximumRedeliveryDelay(3000)
            .retryAttemptedLogLevel(LoggingLevel.INFO)
            .log(LoggingLevel.WARN, "Failed to send message ${body}") // body is not null here
            .log(LoggingLevel.WARN, "Sending message to the error queue: ${body}")   // body is null here
            .to("jms:queue:dslError")
            .end()
        .log(LoggingLevel.INFO, "Sending message ...")
        .setHeader("bridgeDestination", constant(destination))
        .to(destination)
        .log(LoggingLevel.INFO, "received back: ${body}")
        .routeId("example-dsl");

If an exception is thrown, for instance, a ConnectionException due to unavailability of the backend web service, the onException() route will be executed. The first log endpoint:

.log(LoggingLevel.WARN, "Failed to send message ${body}") 

prints out camel exchange IN message body without any problem. However, the second log endpoint:

.log(LoggingLevel.WARN, "Sending message to the error queue: ${body}")

prints out a "Sending message to the error queue: null".

Any reason why the message body becomes a null in this case?

Environment

  • JBoss Fuse 6.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content