activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Timothy Bish (JIRA)" <>
Subject [jira] Commented: (AMQNET-294) durable subscription message loss when master broker fails to slave
Date Tue, 21 Dec 2010 20:15:02 GMT


Timothy Bish commented on AMQNET-294:

Here's a simple consumer that listens to the events, you just need to code up the close of
the MessageConsumer and recreate it in the callback.


using System;
using System.Threading;
using System.Text;
using System.Net;
using Apache.NMS;
using Apache.NMS.ActiveMQ;
using Apache.NMS.ActiveMQ.Commands;

namespace SimpleConsumer
    public class SimpleConsumer
        private IConnection connection;
        private ISession session;
        private IMessageConsumer consumer;
        private IDestination destination;
        public SimpleConsumer()

        public void Connect()
            Apache.NMS.ActiveMQ.ConnectionFactory factory = new ConnectionFactory(
            connection = factory.CreateConnection();
            connection.ConnectionInterruptedListener += new ConnectionInterruptedListener(OnTransportInterrupted);
            connection.ConnectionResumedListener += new ConnectionResumedListener(OnTransportResumed);
            session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
            destination = session.GetQueue("TEST-FOO");
            consumer = session.CreateConsumer(destination);
            consumer.Listener += new MessageListener(OnMessage);

        protected void OnTransportInterrupted()
            Console.WriteLine("***** Connection Reports the Transport Was Interrupted. *****");

        protected void OnTransportResumed()
            Console.WriteLine("***** Connection Reports the Transport Was Restored. *****");

        protected void OnMessage(IMessage message)
            bool wasCompressed = (message as ActiveMQMessage).Compressed;
            string compressedState = wasCompressed ? "Compressed" : "Uncompressed";

            Console.WriteLine("OnMessage Called with a {0} message of Type: {1}",
                              compressedState, message.GetType().Name);

            if(message is ITextMessage)
                ITextMessage textMsg = message as ITextMessage;
                Console.WriteLine("Message was ITextMessage, value of Text = " + textMsg.Text);

        public void Close()
        public void Run()



> durable subscription message loss when master broker fails to slave
> -------------------------------------------------------------------
>                 Key: AMQNET-294
>                 URL:
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>          Components: NMS
>    Affects Versions: 1.4.1
>         Environment: Windows 7 (client), Windows Server 2008 64-bit (server brokers run
on), Sql Server 2008 (database)
>            Reporter: Mark Gellings
>            Assignee: Jim Gomes
>             Fix For: 1.5.0
>         Attachments: Apache.NMS.Test (2).zip,, DurableConsumerTest.cs,, NMSLog.txt, NMSLogLocalFreshCannedActiveMQ542Broker.txt,
> We are seeing message loss on a durable subscription when using NMS ActiveMQ v1.4.1 and
ActiveMQ v5.4.1.
> Please run the included NUnit test and watch the console output.  When it says "Failover
the broker now!" do as it says.  About 75% of the time less than half of the expected 250
messages come through.
> Using version 1.1 of NMS the majority of the time the test passes.  I have seen it fail
only a few times with this earlier version, and when it does there are only a couple messages
that don't come through.
> In the zip file will be the unit test, and a config directory containing the master and
slave activemq configurations.  We are using JDBC master/slave.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message