Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12249

Camel-JMS: transferExchange - send ExchangeProperties can not be accessed before first endpoint in route

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.20.2
    • 2.21.0
    • came-jms
    • None
    • Unknown

    Description

      I am using Camel 2.20.2 and ActiveMQ 5.14.5 with the transferExchange option enabled. When I read a message from a queue the send custom ExchangeProperties are not set. After the exchange is routed to the first endpoint the send ExchangeProperties are set.

      Unittest to replicate:

      public class JmsTransferExchangeAccessExchangePropertiesBeforeFirstEndpointTest extends CamelTestSupport {
      
          @Test
          public void testSendExchangeAndAccessExchangePropertiesBeforeFirstEndpoint() throws Exception {
              MockEndpoint mock = getMockEndpoint("mock:result");
              mock.expectedBodiesReceived("Hello World");
              mock.expectedPropertyReceived("bar", 123);
      
              template.send("direct:start", new Processor() {
      
                  public void process(Exchange exchange) throws Exception {
                      exchange.getIn().setBody("Hello World");
                      exchange.setProperty("bar", 123);
                  }
              });
      
              assertMockEndpointsSatisfied();
          }
      
          @Override
          protected RouteBuilder createRouteBuilder() throws Exception {
              return new RouteBuilder() {
      
                  @Override
                  public void configure() throws Exception {
                      from("direct:start").to(getUri());
                      from(getUri())
                              // .to("log:debug") this line has uncommented to make the test pass
                              .choice().when(exchangeProperty("bar").isEqualTo(123)).to("mock:result");
                  }
              };
          }
          
          protected String getUri() {
              return "activemq:queue:foo?transferExchange=true";
          }
      
          protected CamelContext createCamelContext() throws Exception {
              CamelContext camelContext = super.createCamelContext();
      
              ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
              camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
              return camelContext;
          }
      }
      

      The test fails, but if I uncomment the .to("log:debug") line it passes.

      The test also fails with current master of camel.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            pascalschumacher Pascal Schumacher
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: