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

Reply via email to