I´ve changed the unit test. Now i´m using the CamelJmsTestHelper for the
JmsComponent (now there´s no external broker) and i´ve added setAssertPeriod
to the mock.

/**
 * @author anacortes
 */
public class JmsReplyToCacheLevelNameTest extends CamelTestSupport {
    
    protected CamelContext createCamelContext() throws Exception { 
        CamelContext camelContext = super.createCamelContext(); 
        
        ConnectionFactory connectionFactory =
CamelJmsTestHelper.createPersistentConnectionFactory(); 
        ActiveMQComponent activemqComponent = new ActiveMQComponent(); 
        activemqComponent.setReplyToCacheLevelName("CACHE_NONE"); 
        activemqComponent.setConnectionFactory(connectionFactory); 
        camelContext.addComponent("activemq", activemqComponent); 
        
        return camelContext; 
    } 
    
    @Test 
    public void testStuckMessagesWithFixedReplyQueue() throws Exception { 
        getMockEndpoint("mock:result").expectedMessageCount(1); 
        getMockEndpoint("mock:result").setAssertPeriod(200);
        
        new MyThread().start(); 
        new MyThread().start(); 
        new MyThread().start(); 

        assertMockEndpointsSatisfied(); 
    } 

    @Override 
    protected RouteBuilder createRouteBuilder() throws Exception { 
        return new RouteBuilder() { 
            public void configure() throws Exception { 
                from("direct:start") 
                        .inOut("activemq:queue:foo?replyTo=queue:bar") 
                        .to("mock:result"); 

                from("activemq:queue:foo").transform(body().prepend("Bye
")); 
            } 
        }; 
    } 
    
    class MyThread extends Thread {         
        public void run() { 
            template.requestBody("direct:start", "Camel"+getName(),
String.class);             
        }         
    } 

}

Here we can see that the mock only receives one message (and not the three
messages). 

If we add to the CachingConnectionFactory, cacheConsumer to false, then the
mock will receive the three messages (the stuck messages are gone).

cached.setCacheConsumers(false);




--
View this message in context: 
http://camel.465427.n5.nabble.com/JMS-Shared-fixed-reply-queue-doesn-t-consume-all-the-messages-tp5721700p5722598.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to