You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Bryan Murphy <bm...@gmail.com> on 2009/03/30 20:11:57 UTC

NMS Connection Settings

Hey guys,

I'm back on our ActiveMQ connection problems (again!).  I'm deep
diving into the code, and trying to understand what is going on.  Our
message queues get stuck, sometimes it takes a couple days, but
inevitably it happens forcing a restart of the server and all services
that connect to the server.  This is starting to become and
administrative burden (not to mention an inconvenience for our users).

Anyway, I was debugging a trunk build I made this morning, and I
noticed some of my settings were not reflected when I was browsing
around in the watch list.  I wrote a unit test, and it verified what I
was seeing in my debugger.

Here's the unit test.  Could somebody point out if I'm doing something
obviously wrong?  Every assertion in this unit test fails.  Should I
be using the v1.0.0 branch in svn instead of the trunk?

Thanks,
Bryan

[Test]
public void TestActiveMQConfiguration()
{
	var connectionString = "tcp://127.0.0.1:61616"
		+ "?connection.requestTimeout=60000"
		+ "&consumer.maximumRedeliveryCount=5"
		+ "&session.prefetchSize=1"
		+ "&transport.sendTimeout=30000"
		+ "&transport.receiveTimeout=30000"
		+ "&wireFormat.tcpNoDelayEnabled=true"
		+ "&wireFormat.maxInactivityDuration=120000"
	;

	var connectionFactory = new ConnectionFactory(connectionString);

	using (var connection = (Connection)connectionFactory.CreateConnection())
	{
		Assert.AreEqual(60000.0, connection.RequestTimeout.TotalMilliseconds);

		var transport = this.GetTcpTransport(connection.ITransport);
		Assert.AreEqual(60000.0, transport.RequestTimeout.TotalMilliseconds);
		Assert.IsTrue(transport.TcpNoDelayEnabled);

		var wireFormat = (OpenWireFormat)transport.Wireformat;
		Assert.AreEqual(120000, wireFormat.MaxInactivityDuration);
		Assert.IsTrue(wireFormat.TcpNoDelayEnabled);

		using (var session =
(Session)connection.CreateSession(AcknowledgementMode.Transactional))
		{
			Assert.AreEqual(1, session.PrefetchSize);

			var queue = session.GetQueue("TestQueue");

			using (var consumer = (MessageConsumer)session.CreateConsumer(queue))
			{
				Assert.AreEqual(5, consumer.MaximumRedeliveryCount);
				Assert.AreEqual(0, consumer.RedeliveryTimeout);
			}

			using (var producer = (MessageProducer)session.CreateProducer(queue))
			{
				Assert.AreEqual(60000.0, producer.RequestTimeout.TotalMilliseconds);
			}
		}
	}
}

protected TcpTransport GetTcpTransport(ITransport transport)
{
	while (transport is TransportFilter)
	{
		var filter = (TransportFilter)transport;
		var field = transport.GetType().GetField("next",
BindingFlags.GetField | BindingFlags.Instance |
BindingFlags.NonPublic);
		transport = (ITransport)field.GetValue(filter);
	}

	return (TcpTransport)transport;
}

Re: NMS Connection Settings

Posted by Jim Gomes <e....@gmail.com>.
The first thing I would change in your test code is don't compare floating
point  numbers for equality.  Rounding errors are too easy to encounter.
Instead, cast both to int or long and compare them that way.

Otherwise, this looks like a great unit test to add to the repertoire.  Post
a message if you have any problems entering a JIRA.

Best,
Jim

On Mon, Mar 30, 2009 at 11:11 AM, Bryan Murphy <bm...@gmail.com>wrote:

> Hey guys,
>
> I'm back on our ActiveMQ connection problems (again!).  I'm deep
> diving into the code, and trying to understand what is going on.  Our
> message queues get stuck, sometimes it takes a couple days, but
> inevitably it happens forcing a restart of the server and all services
> that connect to the server.  This is starting to become and
> administrative burden (not to mention an inconvenience for our users).
>
> Anyway, I was debugging a trunk build I made this morning, and I
> noticed some of my settings were not reflected when I was browsing
> around in the watch list.  I wrote a unit test, and it verified what I
> was seeing in my debugger.
>
> Here's the unit test.  Could somebody point out if I'm doing something
> obviously wrong?  Every assertion in this unit test fails.  Should I
> be using the v1.0.0 branch in svn instead of the trunk?
>
> Thanks,
> Bryan
>
> [Test]
> public void TestActiveMQConfiguration()
> {
>        var connectionString = "tcp://127.0.0.1:61616"
>                + "?connection.requestTimeout=60000"
>                + "&consumer.maximumRedeliveryCount=5"
>                + "&session.prefetchSize=1"
>                + "&transport.sendTimeout=30000"
>                + "&transport.receiveTimeout=30000"
>                + "&wireFormat.tcpNoDelayEnabled=true"
>                + "&wireFormat.maxInactivityDuration=120000"
>        ;
>
>        var connectionFactory = new ConnectionFactory(connectionString);
>
>        using (var connection =
> (Connection)connectionFactory.CreateConnection())
>        {
>                Assert.AreEqual(60000.0,
> connection.RequestTimeout.TotalMilliseconds);
>
>                var transport = this.GetTcpTransport(connection.ITransport);
>                Assert.AreEqual(60000.0,
> transport.RequestTimeout.TotalMilliseconds);
>                Assert.IsTrue(transport.TcpNoDelayEnabled);
>
>                var wireFormat = (OpenWireFormat)transport.Wireformat;
>                Assert.AreEqual(120000, wireFormat.MaxInactivityDuration);
>                Assert.IsTrue(wireFormat.TcpNoDelayEnabled);
>
>                using (var session =
> (Session)connection.CreateSession(AcknowledgementMode.Transactional))
>                {
>                        Assert.AreEqual(1, session.PrefetchSize);
>
>                        var queue = session.GetQueue("TestQueue");
>
>                        using (var consumer =
> (MessageConsumer)session.CreateConsumer(queue))
>                        {
>                                Assert.AreEqual(5,
> consumer.MaximumRedeliveryCount);
>                                Assert.AreEqual(0,
> consumer.RedeliveryTimeout);
>                        }
>
>                        using (var producer =
> (MessageProducer)session.CreateProducer(queue))
>                        {
>                                Assert.AreEqual(60000.0,
> producer.RequestTimeout.TotalMilliseconds);
>                        }
>                }
>        }
> }
>
> protected TcpTransport GetTcpTransport(ITransport transport)
> {
>        while (transport is TransportFilter)
>        {
>                var filter = (TransportFilter)transport;
>                var field = transport.GetType().GetField("next",
> BindingFlags.GetField | BindingFlags.Instance |
> BindingFlags.NonPublic);
>                transport = (ITransport)field.GetValue(filter);
>        }
>
>        return (TcpTransport)transport;
> }
>

Re: NMS Connection Settings

Posted by Timothy Bish <ta...@gmail.com>.
On Mon, 2009-03-30 at 13:11 -0500, Bryan Murphy wrote:
> Hey guys,
> 
> I'm back on our ActiveMQ connection problems (again!).  I'm deep
> diving into the code, and trying to understand what is going on.  Our
> message queues get stuck, sometimes it takes a couple days, but
> inevitably it happens forcing a restart of the server and all services
> that connect to the server.  This is starting to become and
> administrative burden (not to mention an inconvenience for our users).
> 
> Anyway, I was debugging a trunk build I made this morning, and I
> noticed some of my settings were not reflected when I was browsing
> around in the watch list.  I wrote a unit test, and it verified what I
> was seeing in my debugger.
> 
> Here's the unit test.  Could somebody point out if I'm doing something
> obviously wrong?  Every assertion in this unit test fails.  Should I
> be using the v1.0.0 branch in svn instead of the trunk?
> 
> Thanks,
> Bryan

I'd recommend opening a Jira issue and attaching your unit test code
there (and granting the ASF license to it of course).  We can take a
look and see what's going on here.  

Regards
Tim

> 
> [Test]
> public void TestActiveMQConfiguration()
> {
> 	var connectionString = "tcp://127.0.0.1:61616"
> 		+ "?connection.requestTimeout=60000"
> 		+ "&consumer.maximumRedeliveryCount=5"
> 		+ "&session.prefetchSize=1"
> 		+ "&transport.sendTimeout=30000"
> 		+ "&transport.receiveTimeout=30000"
> 		+ "&wireFormat.tcpNoDelayEnabled=true"
> 		+ "&wireFormat.maxInactivityDuration=120000"
> 	;
> 
> 	var connectionFactory = new ConnectionFactory(connectionString);
> 
> 	using (var connection = (Connection)connectionFactory.CreateConnection())
> 	{
> 		Assert.AreEqual(60000.0, connection.RequestTimeout.TotalMilliseconds);
> 
> 		var transport = this.GetTcpTransport(connection.ITransport);
> 		Assert.AreEqual(60000.0, transport.RequestTimeout.TotalMilliseconds);
> 		Assert.IsTrue(transport.TcpNoDelayEnabled);
> 
> 		var wireFormat = (OpenWireFormat)transport.Wireformat;
> 		Assert.AreEqual(120000, wireFormat.MaxInactivityDuration);
> 		Assert.IsTrue(wireFormat.TcpNoDelayEnabled);
> 
> 		using (var session =
> (Session)connection.CreateSession(AcknowledgementMode.Transactional))
> 		{
> 			Assert.AreEqual(1, session.PrefetchSize);
> 
> 			var queue = session.GetQueue("TestQueue");
> 
> 			using (var consumer = (MessageConsumer)session.CreateConsumer(queue))
> 			{
> 				Assert.AreEqual(5, consumer.MaximumRedeliveryCount);
> 				Assert.AreEqual(0, consumer.RedeliveryTimeout);
> 			}
> 
> 			using (var producer = (MessageProducer)session.CreateProducer(queue))
> 			{
> 				Assert.AreEqual(60000.0, producer.RequestTimeout.TotalMilliseconds);
> 			}
> 		}
> 	}
> }
> 
> protected TcpTransport GetTcpTransport(ITransport transport)
> {
> 	while (transport is TransportFilter)
> 	{
> 		var filter = (TransportFilter)transport;
> 		var field = transport.GetType().GetField("next",
> BindingFlags.GetField | BindingFlags.Instance |
> BindingFlags.NonPublic);
> 		transport = (ITransport)field.GetValue(filter);
> 	}
> 
> 	return (TcpTransport)transport;
> }
-- 
Tim Bish
http://fusesource.com
http://timbish.blogspot.com/