activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anujjain <>
Subject Error writing to broker. Transport connection is closed.
Date Thu, 08 Jan 2009 09:46:46 GMT

Hi, I new to ActiveMQ. I trying to build a .NET client by using NMS 1.1 for
ActiveMQ 4.1.1. I wrote a simple publisher program by sending two messages.
I worked fine then but if I give a Sleep time of 60000(1 min). First message
is sent fine, butbefore sending the second message I am getting following
System.InvalidOperationException: Error writing to broker.  Transport
connection is closed.
   at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransport.Oneway(Command command)
: Transport connection error: Error writing to broker.  Transport connection
is closed.
I did the same exercise with Java API, and it was working fine. Following is
the exact code in C#
        const string TOPIC_NAME = "SampleSubscriptionTopic";
        const string BROKER = "tcp://localhost:61616";
        const string CLIENT_ID = "ActiveMqFirstSubscriber1";
        const string CONSUMER_ID = "ActiveMqFirstSubscriber1";

        static void Main(string[] args)
               IConnectionFactory factory = new ConnectionFactory(BROKER);
                IConnection con = factory.CreateConnection();
                ISession sess = con.CreateSession();
                ActiveMQTopic topic = new ActiveMQTopic(TOPIC_NAME);
                IMessageProducer prod = sess.CreateProducer(topic);
                for (int i = 0; i < 2; i++)
                    ActiveMQTextMessage message = new
ActiveMQTextMessage("this is from C# client " + i);
                    Console.WriteLine("Message number "+i+" send");
            catch (Exception ex)
                Console.WriteLine("Press any key to exit...");

Can any one please suggest me what is missing in the above code?
View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message