Return-Path: Delivered-To: apmail-geronimo-activemq-users-archive@www.apache.org Received: (qmail 63923 invoked from network); 17 Aug 2006 15:01:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Aug 2006 15:01:37 -0000 Received: (qmail 65812 invoked by uid 500); 17 Aug 2006 15:01:37 -0000 Delivered-To: apmail-geronimo-activemq-users-archive@geronimo.apache.org Received: (qmail 65623 invoked by uid 500); 17 Aug 2006 15:01:36 -0000 Mailing-List: contact activemq-users-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-users@geronimo.apache.org Delivered-To: mailing list activemq-users@geronimo.apache.org Received: (qmail 65614 invoked by uid 99); 17 Aug 2006 15:01:36 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Aug 2006 08:01:36 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of lists@nabble.com designates 72.21.53.35 as permitted sender) Received: from [72.21.53.35] (HELO talk.nabble.com) (72.21.53.35) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Aug 2006 08:01:34 -0700 Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1GDjMw-0007Fy-0G for activemq-users@geronimo.apache.org; Thu, 17 Aug 2006 08:01:14 -0700 Message-ID: <5852879.post@talk.nabble.com> Date: Thu, 17 Aug 2006 08:01:13 -0700 (PDT) From: AFinnell To: activemq-users@geronimo.apache.org Subject: Re: Durable topic subscription needs pump primed. In-Reply-To: <5852831.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit References: <5839659.post@talk.nabble.com> <5852831.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I'm using ActiveMQ version 4.0.1 AFinnell wrote: > > Notice that count is 0 when the consumer is created again, once another > message is sent, all of a sudden two messages are received. > > This NUnit verifies what I said, not what should happen. > > ------ > > using System; > using System.Collections.Generic; > using System.Text; > > using NUnit.Framework; > using NUnit.Extensions; > using ActiveMQ; > using NMS; > using ActiveMQ.Commands; > using System.Threading; > > namespace ActiveMQDurableTest > { > [TestFixture] > public class DurableTest > { > private static string TOPIC = "TestTopic"; > > private static String URI = "tcp://localhost:61616"; > > private static String CLIENT_ID = "DurableClientId"; > > private static String CONSUMER_ID = "ConsumerId"; > > private static ConnectionFactory FACTORY = new > ConnectionFactory(new Uri(URI)); > > private int count = 0; > > public void RegisterDurableConsumer() > { > using (IConnection connection = FACTORY.CreateConnection()) > { > connection.ClientId = CLIENT_ID; > connection.Start(); > > using (ISession session = > connection.CreateSession(AcknowledgementMode.DupsOkAcknowledge)) > { > ITopic topic = session.GetTopic(TOPIC); > IMessageConsumer consumer = > session.CreateDurableConsumer(topic, CONSUMER_ID, "2 > 1", false); > consumer.Dispose(); > } > > connection.Stop(); > } > } > > public void SendPersistentMessage() > { > using (IConnection connection = FACTORY.CreateConnection()) > { > connection.Start(); > using (ISession session = > connection.CreateSession(AcknowledgementMode.DupsOkAcknowledge)) > { > ITopic topic = session.GetTopic(TOPIC); > ActiveMQTextMessage message = new > ActiveMQTextMessage("Hello"); > message.NMSPersistent = true; > message.Persistent = true; > > IMessageProducer producer = session.CreateProducer(); > producer.Send(topic, message); > producer.Dispose(); > } > connection.Stop(); > } > } > > [Test] > public void TestMe() > { > count = 0; > > RegisterDurableConsumer(); > SendPersistentMessage(); > > using (IConnection connection = FACTORY.CreateConnection()) > { > connection.ClientId = CLIENT_ID; > connection.Start(); > > using (ISession session = > connection.CreateSession(AcknowledgementMode.DupsOkAcknowledge)) > { > ITopic topic = session.GetTopic(TOPIC); > IMessageConsumer consumer = > session.CreateDurableConsumer(topic, CONSUMER_ID, "2 > 1", false); > consumer.Listener += new > MessageListener(consumer_Listener); > > /// Don't know how else to give the system enough > time. > /// > Thread.Sleep(5000); > > Assert.AreEqual(0, count); > > Console.WriteLine("Count = " + count); > > SendPersistentMessage(); > > Thread.Sleep(5000); > > Assert.AreEqual(2, count); > > Console.WriteLine("Count = " + count); > > consumer.Dispose(); > } > > connection.Stop(); > } > } > > /// > /// > /// > /// > private void consumer_Listener(IMessage message) > { > ++count; > } > } > } > > > James.Strachan wrote: >> >> Which version of ActiveMQ are you using BTW? >> Any chance you could refactor your test code into an NUnit test case? >> >> On 8/16/06, AFinnell wrote: >>> >>> I'm using the NMS client for C# and it appears that the durable messages >>> need >>> something to prime the pump. >>> >>> Steps to reproduce: >>> >>> Note: I am using the Listener handler on the IMessageConsumer object for >>> an >>> asynch response. >>> >>> 1. Sign on with durable topic subscription >>> 2. Disconnect client >>> 3. Send a persistent message >>> 4. Sign back on to durable topic subscription >>> (At this point the message is not sent to the client) >>> 5. Send a new message to the client >>> 6. Both messages are now received. >>> >>> I can post my code as needed. Is the problem I'm having apparent to >>> anyone? >>> >>> Andrew >>> -- >>> View this message in context: >>> http://www.nabble.com/Durable-topic-subscription-needs-pump-primed.-tf2117517.html#a5839659 >>> Sent from the ActiveMQ - User forum at Nabble.com. >>> >>> >> >> >> -- >> >> James >> ------- >> http://radio.weblogs.com/0112098/ >> >> > > -- View this message in context: http://www.nabble.com/Durable-topic-subscription-needs-pump-primed.-tf2117517.html#a5852879 Sent from the ActiveMQ - User forum at Nabble.com.