activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Murphy <bmurphy1...@gmail.com>
Subject NMS Connection Settings
Date Mon, 30 Mar 2009 18:11:57 GMT
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;
}

Mime
View raw message