activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AFinnell <and...@activesol.net>
Subject Re: Durable topic subscription needs pump primed.
Date Fri, 18 Aug 2006 18:46:45 GMT


Thanks for the quick response and fix. I'm interested in seeing what was
changed.


James.Strachan wrote:
> 
> I've just applied your test case to SVN along with a fix and a fix for
> AMQ-883 and AMQ-865 if you want to try it out. Many thanks to Bryan
> Schmidt who popped by on IRC and gave me a fix and suggestions on how
> to deal with C# event delegates.
> 
> On 8/17/06, James Strachan <james.strachan@gmail.com> wrote:
>> This is sounding a bit like this issue...
>>
>> https://issues.apache.org/activemq/browse/AMQ-865
>>
>> thanks for the test case, have added it to that issue. We'll take a look.
>>
>> On 8/17/06, AFinnell <andrew@activesol.net> 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();
>> >             }
>> >         }
>> >
>> >         /// <summary>
>> >         ///
>> >         /// </summary>
>> >         /// <param name="message"></param>
>> >         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 <andrew@activesol.net> 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#a5852831
>> > Sent from the ActiveMQ - User forum at Nabble.com.
>> >
>> >
>>
>>
>> --
>>
>> James
>> -------
>> http://radio.weblogs.com/0112098/
>>
> 
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

-- 
View this message in context: http://www.nabble.com/Durable-topic-subscription-needs-pump-primed.-tf2117517.html#a5875406
Sent from the ActiveMQ - User forum at Nabble.com.


Mime
View raw message