|
Hello, using Camel 2.9.1 and Junit 4 unit tsts,
I ran into issues testing a simple route: when I add the threads() at the beginning of the route the test hangs and I need to manually stop it. Is this the route I am trying to test: from(MAIN_INBOUND_QUEUE) .threads(3) .doTry() .to(INBOUND_QUEUE1, INBOUND_QUEUE2) .doCatch(Exception.class) .process(new CounterHeaderIncrementorProcessor(Constants.MY_REDELIVERIES_COUNTER_HEADER, 1)) .choice() .when(header(Constants.MY_REDELIVERIES_COUNTER_HEADER).isLessThanOrEqualTo(redeliveriesCount)) .to(MAIN_INBOUND_QUEUE).stop() .otherwise() .to(DEAD_LETTER_QUEUE).stop() .end() .end() ; and this is the unit test I am performing: ublic class TopicSimulatorRoutesBuilderErrorHandlingTest extends CamelTestSupport { protected String mainInbound = "direct:MAIN_INBOUND_QUEUE"; protected String deadLetterQueue = "mock:INBOUND_DEADLETTER"; protected String inbound1 = "mock:INBOUND1"; protected String inbound2 = "mock:INBOUND2"; protected int maxRedeliveries = 3; protected int redeliveryDelay = 0; @Override protected RouteBuilder createRouteBuilder() { return new MyRouteBuilder(context.createProducerTemplate(), mainInbound, inbound2, inbound1, deadLetterQueue, 1, maxRedeliveries); } @Test public void testErrorHandlingOnFirstDestination() throws Exception { context.getRouteDefinitions().get(0).adviceWith(context, new RouteBuilder() { @Override public void configure() throws Exception { interceptSendToEndpoint(inbound1) .throwException(new Exception("Simulated error")); } }); context.start(); getMockEndpoint("mock:"+mainInbound).expectedMessageCount(1+maxRedeliveries); getMockEndpoint(inbound2).expectedMessageCount(0); getMockEndpoint(inbound1).expectedMessageCount(0); getMockEndpoint(deadLetterQueue).expectedMessageCount(1); template.sendBody(mainInbound,"msg"); assertNotNull(context.hasEndpoint(mainInbound)); assertNotNull(context.hasEndpoint(inbound1)); assertNotNull(context.hasEndpoint(inbound2)); assertNotNull(context.hasEndpoint(deadLetterQueue)); log.info("#### Received Messages Count: {} {} {} {} {} {} {} {}", new Object[]{ mainInbound,getMockEndpoint("mock:"+mainInbound).getReceivedCounter(), inbound2,getMockEndpoint(inbound2).getReceivedCounter(), inbound1,getMockEndpoint(inbound1).getReceivedCounter(), deadLetterQueue,getMockEndpoint(deadLetterQueue).getReceivedCounter() }); assertMockEndpointsSatisfied(); } @Override public boolean isUseAdviceWith() { return true; } @Override public String isMockEndpoints() { return "*"; } @Override public boolean isUseDebugger() { return false; } @Override protected void debugBefore(Exchange exchange, Processor processor, ProcessorDefinition definition, String id, String shortName) { log.error("Before " + definition + " with exchange.getI() " + exchange.getIn()); } } if I comment the threads() in the queue, the test works, otherwise it hangs. |
|
This is the message in the test log where it hangs:
[Camel Thread 4 - Threads] TRACE o.a.camel.util.AsyncProcessorHelper - Waiting for asynchronous callback before continuing for exchangeId: ... |
|
I've also tried removing the "threads()" using the weaveByType, but I get an "unsupported operation exception" during the test execution.
|
|
Hi
Can you try to run the test on the trunk code? If the error is still there, you can log a JIRA and submit your test case with it. On Mon Jun 25 22:22:34 2012, E.Gherardini wrote: > I've also tried removing the "threads()" using the weaveByType, but I get an > "unsupported operation exception" during the test execution. > > -- > View this message in context: http://camel.465427.n5.nabble.com/Threads-EIP-hangs-Unit-Tests-JUnit4-tp5715031p5715053.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Willem ---------------------------------- FuseSource Web: http://www.fusesource.com Blog: http://willemjiang.blogspot.com (English) http://jnn.javaeye.com (Chinese) Twitter: willemjiang Weibo: willemjiang |
|
I will and let you know.
|
|
This issue reproduces also on trunk.
I am opening a jira issue. |
|
Created jira issue:
https://issues.apache.org/jira/browse/CAMEL-5406 |
| Powered by Nabble | Edit this page |
