activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robottaway <>
Subject AMQ shut down, NMS connection still going!
Date Wed, 01 Nov 2006 18:03:56 GMT

I am running a Windows service that  connects to AMQ 4.0.2 thourgh the .NET
NMS api. It works almost perfect but there seems be one sticking point,
which is if I kill AMQ the service keeps on going like nothing happened!

I have tried using both Receive() and Receive(span) methods, niether throw
exception when AMQ is no longer running.

here is a .NET console app I wrote to make testing this easy. Just run it
wait for the message "Before Receive()", then kill AMQ. Nothing happens in
the app! It seems to think things are still going good.

using System;
using System.Collections.Generic;
using System.Text;
using NMS;
using ActiveMQ;
using ActiveMQ.Commands;
using System.Threading;

namespace TestKillAmq
    class Program
        static String connString = "tcp://";

        static String queue = "bsd.development.orderentry";

        static void Main(string[] args)
            IConnectionFactory factory;
            Connection amqConnection;
            Session amqSession;
            IDestination destination;
            IMessageConsumer consumer;
            ActiveMQTextMessage message;

            factory = new ConnectionFactory(new Uri(connString));
                amqConnection = (Connection)factory.CreateConnection();

                amqSession =

                destination = amqSession.GetQueue(queue);

                consumer = amqSession.CreateConsumer(destination);

                Console.WriteLine("Before Receive()");

                message = (ActiveMQTextMessage)consumer.Receive();

                Console.WriteLine("After Receive(), message: " +


                Console.WriteLine("Commited transaction!");

                // shutdown all the stuff

            catch (Exception exception)

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message