camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Müller <christian.muel...@gmail.com>
Subject Re: DeadLetterErrorHandler queue not created
Date Sat, 05 Oct 2013 15:57:48 GMT
Sorry for the late response. I have build the following unit test which
show it works (I have attached the entire project also):

package org.apache.cmueller.camel.test;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import org.apache.activemq.broker.BrokerService;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.DeadLetterChannelBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.processor.RedeliveryPolicy;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class DeadLetterErrorHandlerTest extends CamelTestSupport {

    private BrokerService broker;
    private final CountDownLatch latch = new CountDownLatch(6);

    @Before
    public void setUp() throws Exception {
        broker = new BrokerService();
        broker.setPersistent(false);
        broker.setUseJmx(false);
        broker.addConnector("tcp://localhost:61616");
        broker.start();

        super.setUp();
    }

    @After
    public void tearDown() throws Exception {
        super.tearDown();

        broker.stop();
    }

    @Test
    public void measureJmsMessageInOutExchangePatternWithReplyToExecution()
throws Exception {
        getMockEndpoint("mock:end").expectedMessageCount(0);
        getMockEndpoint("mock:end").setSleepForEmptyTest(10000);

        template.sendBody("activemq:queue:weca", "Text Message");

        assertTrue(latch.await(10, TimeUnit.SECONDS));

        assertEquals("Text Message",
consumer.receiveBody("activemq:queue:wecaDLQ"));
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() throws Exception {
                RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
                redeliveryPolicy.setMaximumRedeliveries(5);
                redeliveryPolicy.setRedeliveryDelay(1000);

                DeadLetterChannelBuilder deadLetterChannelBuilder = new
DeadLetterChannelBuilder();

deadLetterChannelBuilder.setDeadLetterUri("activemq:queue:wecaDLQ");

deadLetterChannelBuilder.setRedeliveryPolicy(redeliveryPolicy);
                deadLetterChannelBuilder.setUseOriginalMessage(true);

                context.setErrorHandlerBuilder(deadLetterChannelBuilder);

                context.setTracing(true);

                from("activemq:queue:weca")
                    .process(new Processor() {
                        public void process(Exchange exchange) throws
Exception {
                            latch.countDown();
                            throw new Exception("forced by unit test");
                        }
                    })
                    .to("mock:end");
            }
        };
    }
}

Hope this helps.

Best,

Christian
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Mon, Jul 15, 2013 at 1:07 PM, shin938 <shalom938@gmail.com> wrote:

> Thanks  Christian,
> Yes, its a copy paste modify issue, the configuration is ok and the
> redeliveries work.
> I tried many times , I do get the redeliveries but the DLQ is not created.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/DeadLetterErrorHandler-queue-not-created-tp5735624p5735658.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
View raw message