ActiveMq NMS Disconnects after about 30 seconds
Posted
by Kelly
on Stack Overflow
See other posts from Stack Overflow
or by Kelly
Published on 2010-01-15T16:46:39Z
Indexed on
2010/04/19
7:53 UTC
Read the original article
Hit count: 542
'm trying to do simple pub/sub with ActiveMq. I can get it all working fine, but the subscriber disconnects after about 30 seconds. I've looked for a timeout type of value I can change but nothing seems to be working. Here is the subscriber:
using System;
using Apache.NMS;
using Apache.NMS.ActiveMQ;
using Apache.NMS.ActiveMQ.Commands;
namespace ActiveMQCatcher
{
internal class Program
{
private static void Main(string[] args)
{
IConnectionFactory factory = new ConnectionFactory("tcp://localhost:61616/");
using (IConnection connection = factory.CreateConnection())
{
connection.ClientId = "MYID";
connection.Start();
using (ISession session = connection.CreateSession())
{
IMessageConsumer consumer = session.CreateConsumer(new ActiveMQTopic("MYTOPIC"), null, false);
consumer.Listener += consumer_Listener;
Console.ReadLine();
}
connection.Stop();
}
}
private static void consumer_Listener(IMessage message)
{
Console.WriteLine("Got: " + ((ITextMessage) message).Text);
}
}
}
I tried this:
connection.RequestTimeout = TimeSpan.MaxValue;
But it didn't seem to change anything.
To get the problem just run the program and sit waiting for about 30 seconds. You can see the connection disappear in the ActiveMQ Console (http://localhost:8161/admin/connections.jsp by default)
Any ideas?
© Stack Overflow or respective owner