activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Gomes <e.se...@gmail.com>
Subject Re: NMS Connection Settings
Date Wed, 22 Apr 2009 20:12:04 GMT
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 <bmurphy1976@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;
> }
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message