activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robottaway <rotta...@musiciansfriend.com>
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://172.16.10.243:61616";

        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));
            try
            {
                amqConnection = (Connection)factory.CreateConnection();

                amqSession =
(Session)amqConnection.CreateSession(AcknowledgementMode.Transactional);

                destination = amqSession.GetQueue(queue);

                consumer = amqSession.CreateConsumer(destination);

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

                message = (ActiveMQTextMessage)consumer.Receive();

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

                amqSession.Commit();

                Console.WriteLine("Commited transaction!");

                // shutdown all the stuff
                consumer.Dispose();
                amqSession.Dispose();
                amqConnection.Dispose();

                Thread.Sleep(5000);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
            }
        }
    }
}

-- 
View this message in context: http://www.nabble.com/AMQ-shut-down%2C-NMS-connection-still-going%21-tf2554850.html#a7119119
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message