hey Greg, given that you configured your error handler to do 3 redelivery
attempts (before moving to mock:dead), I think the 2nd retry (or 3rd
message, with MyService.count=3) will succeed and skip the mock:dead
endpoint...only when all attempts of redelivery have failed, will the
Exchange be moved to a dead letter endpoint...


gmcfall wrote:
> 
> Hi,
> 
> I'm a camel newbie and I'm having trouble with the dead message channel.
> 
> In the JUnit test below, I am trying to route dead messages to a mock
> endpoint, but the assertion for the expected message count on this
> endpoint
> is failing.
> For some reason, messages are not being delivered to the "mock:dead"
> endpoint.
> 
> I see the following result for this test:
> 
> *java.lang.AssertionError: *mock://dead Received message count. Expected:
> <2> but was: <0>
> 
> 
> Can someone explain what I am doing wrong?
> 
> 
> public class DeadLetterTest extends CamelTestSupport {
> 
> @EndpointInject(uri = "mock:sink")
> protected MockEndpoint sink;
> 
> @EndpointInject(uri = "mock:dead")
> protected MockEndpoint deadEndpoint;
>  @Produce(uri = "direct:inbox")
> protected ProducerTemplate template;
>  @Test
> public void testDeadLetter() throws Exception {
>  sink.expectedMessageCount(1);
> deadEndpoint.expectedMessageCount(2);
>  template.sendBody("Hello World");
>  sink.assertIsSatisfied();
> deadEndpoint.assertIsSatisfied();
> }
> 
> static public class MyService {
> int count = 0;
>  public String enrich(String body) throws Exception {
> count++;
> if (count < 3) {
> throw new Exception("The Service is unavailable");
> }
> return body + "." + count;
> }
> }
> 
>  @Override
> protected RouteBuilder createRouteBuilder() {
> return new RouteBuilder() {
> 
> @Override
> public void configure() throws Exception {
>  errorHandler(
> deadLetterChannel("mock:dead")
> .maximumRedeliveries(3)
> .redeliveryDelay(500)
> );
>  MyService bean = new MyService();
>  from("direct:inbox")
> .bean(bean, "enrich")
> .to("mock:sink");
> }
> };
> }
> }
> 
> Thanks,
> ~ Greg McFall
> 


-----
Ben O'Day
IT Consultant -http://benoday.blogspot.com

--
View this message in context: 
http://camel.465427.n5.nabble.com/Problem-using-dead-message-channel-tp4425741p4425825.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to