You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by rasitha1 <ra...@gmail.com> on 2011/05/31 18:02:45 UTC

Re: Dead Letter Queue

Hi,

Can you please expand a bit on this? 

"Typically you NAK a message by sending it to some bad message 
destination; i.e. you still consume it."

I'm looking to use "individualDeadLetterStrategy" to separate failed
messages into separate DLQs. But my client code (when using
ClientAcknowledge mode) just creates a message manually to the default DLQ.
(which I'm not sure is the right way) 

Looking at the source I see you need to send a special message
(AckType=PoisonAck) to tell the broker that the message failed. How should I
go about doing that?

At the end I need to get failed messages into separate DLQs while using
ClientAcknowledge mode.

Thanks,
Ras



--
View this message in context: http://activemq.2283324.n4.nabble.com/Dead-Letter-Queue-tp2356685p3563553.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Dead Letter Queue

Posted by nstoyanov <ne...@schneider-electric.com>.
We are also wanting to use the "individualDeadLetterStrategy" and in some
cases send the Poison Ack on the first try. Did anyone manage to do that? We
are using Apache.NMS as well.




--
View this message in context: http://activemq.2283324.n4.nabble.com/Dead-Letter-Queue-tp2356685p4684068.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Dead Letter Queue

Posted by rasitha <ra...@gmail.com>.
I'm not having any luck even with Auto Ack. I'm using Apache.NMS framework
though.

Messages do get to ProcessMessage method but when the exception is thrown,
they don't get to DLQ. 

Do you know what I'm doing wrong here?


    class DeadLetterQueueTest
    {

        static void Main(string[] args)
        {
            Run();
        }

        private static void Run()
        {
            var uri = "failover:tcp://server1:10280";
            var user = "amq";
            var pass = "amq";
            var queue = "dlqtest";
            CreateTestMessage(uri, user, pass, queue);
            StartConsumer(uri, user, pass, queue);
            new ManualResetEvent(false).WaitOne();
        }
        

        private static void StartConsumer(string uri, string user, string
pass, string queue)
        {
            var session = GetSession(uri, user, pass);
            var consumer = session.CreateConsumer(new ActiveMQQueue(queue));
            consumer.Listener += ProcessMessage;
        }

        private static void ProcessMessage(IMessage message)
        {
            Console.WriteLine(message);
            throw new ApplicationException();
        }

        private static void CreateTestMessage(string uri, string user,
string pass, string queue)
        {
            using (var session = GetSession(uri, user, pass))
            {
                using (var producer = session.CreateProducer(new
ActiveMQQueue(queue)))
                {
                    var msg = producer.CreateTextMessage("Hello");
                    producer.Send(msg);
                }
            }
        }

        private static ISession GetSession(string uri, string user, string
pass)
        {
            var factory = new ConnectionFactory(uri);
            var conn = factory.CreateConnection(user, pass);
            IRedeliveryPolicy policy = conn.RedeliveryPolicy;
            policy.InitialRedeliveryDelay = 100;
            policy.UseExponentialBackOff = false;
            policy.MaximumRedeliveries = 0;
            conn.Start();
            conn.RedeliveryPolicy = policy;
            return conn.CreateSession(AcknowledgementMode.AutoAcknowledge);
        }
    }

--
View this message in context: http://activemq.2283324.n4.nabble.com/Dead-Letter-Queue-tp2356685p3564283.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Dead Letter Queue

Posted by Gary Tully <ga...@gmail.com>.
for clientAck, that is needed, have a look at:
org.apache.activemq.ActiveMQMessageConsumer#dispatch

The automatic dlq processing occurs if onMessage throws an exception,
but it is bypassed for transactions and clientack mode as the acking
is out of control of the consumer in that case.

If you use autoack or activemq's individual ack mode, you will get
auto dlq processing (the PoisonAck) if onMessage throws a runtime
exception.

On 31 May 2011 17:02, rasitha1 <ra...@gmail.com> wrote:
> Hi,
>
> Can you please expand a bit on this?
>
> "Typically you NAK a message by sending it to some bad message
> destination; i.e. you still consume it."
>
> I'm looking to use "individualDeadLetterStrategy" to separate failed
> messages into separate DLQs. But my client code (when using
> ClientAcknowledge mode) just creates a message manually to the default DLQ.
> (which I'm not sure is the right way)
>
> Looking at the source I see you need to send a special message
> (AckType=PoisonAck) to tell the broker that the message failed. How should I
> go about doing that?
>
> At the end I need to get failed messages into separate DLQs while using
> ClientAcknowledge mode.
>
> Thanks,
> Ras
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Dead-Letter-Queue-tp2356685p3563553.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
http://fusesource.com
http://blog.garytully.com