camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim <>
Subject Error in MessageSupport when using JMSMessage
Date Wed, 17 Nov 2010 00:25:21 GMT
This is essentially a different incantation of CAMEL-2436
A test case that reproduces the issue is below.
If you have a bean that returns null when processing the body of a
JMSMessage you will not get the null in the next endpoint but rather
the original message itself.
One really hacky way around this bug is to replace the JMSMessage with
a DefaultMessage by adding a processor

                        new Processor() {
                            public void process(@NotNull Exchange
anExchange) throws Exception {
                                final DefaultMessage myIn = new

Into the below code after the from()

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQObjectMessage;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.component.jms.JmsMessage;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.Test;

import javax.jms.JMSException;

public class C2436Test extends CamelTestSupport {
    private static final String ENDPOINT1 = "jms:mock";
    private static final String ENDPOINT2 = "mock:results";
    private static final String TEST_CONTENT = "My Test Content";

    protected RouteBuilder createRouteBuilder() throws Exception {
        context.addComponent("jms", JmsComponent.jmsComponent(new

        return new RouteBuilder() {
            public void configure() throws Exception {
                    .bean(new ReturnsNull())

    public void testRoutePassing() throws InterruptedException, JMSException {
        final MockEndpoint myMockEndpoint = getMockEndpoint(ENDPOINT2);


        final ActiveMQObjectMessage myMessage = new ActiveMQObjectMessage();

        template.send(ENDPOINT1, new Processor() {
            public void process(@NotNull Exchange anExchange) throws Exception {
                anExchange.setIn(new JmsMessage(myMessage, null));


    public class ReturnsNull {
        public String processMessage(@NotNull String aMessage) {
            return null;

View raw message