You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Greg McFall <gr...@gmail.com> on 2011/06/03 20:12:01 UTC

deadLetterChannel with enrich

Hi,

I have the following configuration:

	errorHandler(
		deadLetterChannel("direct:deadChannel")
			.disableRedelivery()
	);
				
			
	from("direct:inbox")
		.enrich("direct:enrich", new MyAggregationStrategy())
		.log("done enriching")
		.to("mock:outbox");
	
	from("direct:enrich")
		.bean(new MockService());
	
	from("direct:deadChannel")
		.log("Received dead message: ${body}")
		.to("mock:dead");


The MockService bean throws an Exception.
With this configuration, a message sent to "direct:inbox" is delivered
to the "mock:dead" endpoint, as expected.
But, the message is also delivered to "mock:outbox", contrary to my
expectaction.

How do I ensure that the route is ended after the message is delivered
to the dead letter channel?

Re: deadLetterChannel with enrich

Posted by boday <be...@initekconsulting.com>.
hmmm...I just tried this and it worked as expected...I made a few tweaks in
place of your bean/aggregator classes...

	@EndpointInject(uri = "mock:outbox")
	protected MockEndpoint mock;
	
	@Test
	public void test() throws Exception {
		mock.expectedMessageCount(0);
		template.sendBody("direct:start", "message");
		mock.assertIsSatisfied();
	}

	@Override
	protected RouteBuilder createRouteBuilder() throws Exception {
		return new RouteBuilder() {
			@Override
			public void configure() throws Exception {

			
errorHandler(deadLetterChannel("direct:deadChannel").disableRedelivery());

				from("direct:start")
				  .log("before enriching")
				  .enrich("direct:enrich", new MyAggregator())
				  .log("done enriching")
				  .to("mock:outbox");

				from("direct:enrich")
				  .throwException(new Exception("test"));

				from("direct:deadChannel")
				  .log("Received dead message: ${body}")
				  .to("mock:dead");
			}
		};
	}



gmcfall wrote:
> 
> Hi,
> 
> I have the following configuration:
> 
> 	errorHandler(
> 		deadLetterChannel("direct:deadChannel")
> 			.disableRedelivery()
> 	);
> 				
> 			
> 	from("direct:inbox")
> 		.enrich("direct:enrich", new MyAggregationStrategy())
> 		.log("done enriching")
> 		.to("mock:outbox");
> 	
> 	from("direct:enrich")
> 		.bean(new MockService());
> 	
> 	from("direct:deadChannel")
> 		.log("Received dead message: ${body}")
> 		.to("mock:dead");
> 
> 
> The MockService bean throws an Exception.
> With this configuration, a message sent to "direct:inbox" is delivered
> to the "mock:dead" endpoint, as expected.
> But, the message is also delivered to "mock:outbox", contrary to my
> expectaction.
> 
> How do I ensure that the route is ended after the message is delivered
> to the dead letter channel?
> 


-----
Ben O'Day
IT Consultant -http://consulting-notes.com

--
View this message in context: http://camel.465427.n5.nabble.com/deadLetterChannel-with-enrich-tp4452052p4452628.html
Sent from the Camel - Users mailing list archive at Nabble.com.