Search in sources :

Example 1 with DeadLetterChannelBuilder

use of org.apache.camel.builder.DeadLetterChannelBuilder in project camel by apache.

the class ContextScopedOnExceptionNotHandledErrorHandlerRefIssueTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry jndi = super.createRegistry();
    jndi.bind("myDLC", new DeadLetterChannelBuilder("mock:dead"));
    return jndi;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) DeadLetterChannelBuilder(org.apache.camel.builder.DeadLetterChannelBuilder)

Example 2 with DeadLetterChannelBuilder

use of org.apache.camel.builder.DeadLetterChannelBuilder in project camel by apache.

the class ContextScopedOnExceptionNotHandledErrorHandlerRefIssueTwoRoutesTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry jndi = super.createRegistry();
    jndi.bind("myDLC", new DeadLetterChannelBuilder("mock:dead"));
    return jndi;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) DeadLetterChannelBuilder(org.apache.camel.builder.DeadLetterChannelBuilder)

Example 3 with DeadLetterChannelBuilder

use of org.apache.camel.builder.DeadLetterChannelBuilder in project camel by apache.

the class ContextScopedOnExceptionNotHandledRouteScopedErrorHandlerRefIssueTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry jndi = super.createRegistry();
    jndi.bind("myDLC", new DeadLetterChannelBuilder("mock:dead"));
    return jndi;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) DeadLetterChannelBuilder(org.apache.camel.builder.DeadLetterChannelBuilder)

Example 4 with DeadLetterChannelBuilder

use of org.apache.camel.builder.DeadLetterChannelBuilder in project camel by apache.

the class OnExceptionContinuedIssueTest method testOnExceptionWrappedMatch.

@Test
public void testOnExceptionWrappedMatch() throws Exception {
    final DefaultErrorHandlerBuilder defaultErrorHandlerBuilder = new DeadLetterChannelBuilder("direct:dead");
    // run fast
    defaultErrorHandlerBuilder.redeliveryDelay(0);
    defaultErrorHandlerBuilder.maximumRedeliveries(2);
    context.setErrorHandlerBuilder(defaultErrorHandlerBuilder);
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            context.setTracing(false);
            onException(OrderFailedException.class).maximumRedeliveries(0).continued(true);
            from("direct:dead").to("log:dead", "mock:dead");
            from("direct:order").to("mock:one").process(new Processor() {

                @Override
                public void process(Exchange exchange) throws Exception {
                    log.info("First Processor Invoked");
                    throw new OrderFailedException("First Processor Failure");
                }
            }).to("mock:two").process(new Processor() {

                @Override
                public void process(Exchange exchange) throws Exception {
                    log.info("Second Processor Invoked");
                }
            }).to("mock:three").process(new Processor() {

                @Override
                public void process(Exchange exchange) throws Exception {
                    log.info("Third Processor Invoked");
                    throw new RuntimeException("Some Runtime Exception");
                }
            }).to("mock:four").process(new Processor() {

                @Override
                public void process(Exchange exchange) throws Exception {
                    log.info("Fourth Processor Invoked");
                }
            });
        }
    });
    context.start();
    // we should only get 1 to the DLC when we hit the 3rd route that
    // throws the runtime exception
    getMockEndpoint("mock:dead").expectedMessageCount(1);
    getMockEndpoint("mock:one").expectedMessageCount(1);
    getMockEndpoint("mock:two").expectedMessageCount(1);
    getMockEndpoint("mock:three").expectedMessageCount(1);
    getMockEndpoint("mock:four").expectedMessageCount(0);
    template.requestBody("direct:order", "Camel in Action");
    assertMockEndpointsSatisfied();
}
Also used : DefaultErrorHandlerBuilder(org.apache.camel.builder.DefaultErrorHandlerBuilder) Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) DeadLetterChannelBuilder(org.apache.camel.builder.DeadLetterChannelBuilder) Test(org.junit.Test)

Example 5 with DeadLetterChannelBuilder

use of org.apache.camel.builder.DeadLetterChannelBuilder in project camel by apache.

the class OnExceptionRouteScopedErrorHandlerRefIssueTwoRoutesTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry jndi = super.createRegistry();
    jndi.bind("myDLC", new DeadLetterChannelBuilder("mock:dead"));
    return jndi;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) DeadLetterChannelBuilder(org.apache.camel.builder.DeadLetterChannelBuilder)

Aggregations

DeadLetterChannelBuilder (org.apache.camel.builder.DeadLetterChannelBuilder)20 JndiRegistry (org.apache.camel.impl.JndiRegistry)16 CamelContext (org.apache.camel.CamelContext)2 Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1 DefaultErrorHandlerBuilder (org.apache.camel.builder.DefaultErrorHandlerBuilder)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)1 RedeliveryPolicy (org.apache.camel.processor.RedeliveryPolicy)1 Test (org.junit.Test)1