activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r424237 - in /incubator/activemq/trunk/activemq-dotnet/src: main/csharp/ActiveMQ/MessageConsumer.cs test/csharp/NMS/AsyncConsumeTest.cs
Date Fri, 21 Jul 2006 09:00:36 GMT
Author: jstrachan
Date: Fri Jul 21 02:00:35 2006
New Revision: 424237

URL: http://svn.apache.org/viewvc?rev=424237&view=rev
Log:
added patch from Matthew Xie. For background see: http://www.nabble.com/Message-recieved-but-can%27t-removed-from-the-amq-server-problem-tf1964193.html#a5429771

Modified:
    incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/MessageConsumer.cs
    incubator/activemq/trunk/activemq-dotnet/src/test/csharp/NMS/AsyncConsumeTest.cs

Modified: incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/MessageConsumer.cs
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/MessageConsumer.cs?rev=424237&r1=424236&r2=424237&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/MessageConsumer.cs (original)
+++ incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/MessageConsumer.cs Fri
Jul 21 02:00:35 2006
@@ -127,7 +127,9 @@
                 IMessage message = dispatcher.DequeueNoWait();
                 if (message != null)
                 {
-                    Listener(message);
+                   //here we add the code that if do acknowledge action.
+                   message = AutoAcknowledge(message);
+                   Listener(message);
                 }
                 else
                 {

Modified: incubator/activemq/trunk/activemq-dotnet/src/test/csharp/NMS/AsyncConsumeTest.cs
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-dotnet/src/test/csharp/NMS/AsyncConsumeTest.cs?rev=424237&r1=424236&r2=424237&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-dotnet/src/test/csharp/NMS/AsyncConsumeTest.cs (original)
+++ incubator/activemq/trunk/activemq-dotnet/src/test/csharp/NMS/AsyncConsumeTest.cs Fri Jul
21 02:00:35 2006
@@ -21,71 +21,95 @@
 
 
 
-namespace NMS
-{
-	[TestFixture]
-    public class AsyncConsumeTest : JMSTestSupport
-    {
-        protected Object semaphore = new Object();
-        protected bool received;
-        
-		[SetUp]
-        override public void SetUp()
+namespace NMS {
+        [ TestFixture ]
+        public class AsyncConsumeTest : JMSTestSupport
         {
-			base.SetUp();
-        }
-		
-        [TearDown]
-        override public void TearDown()
-        {
-			base.TearDown();
-        }
-		
-        [Test]
-        public void TestAsynchronousConsume()
-        {
-			
-			// lets create an async consumer
-			// START SNIPPET: demo
-			IMessageConsumer consumer = Session.CreateConsumer(this.Destination);
-			consumer.Listener += new MessageListener(OnMessage);
-			// END SNIPPET: demo
-			
-			// now lets send a message
-			IMessageProducer producer = CreateProducer();
-			IMessage request = CreateMessage();
-			request.NMSCorrelationID = "abc";
-			request.NMSType = "Test";
-			producer.Send(request);
-			
-			WaitForMessageToArrive();
-            
-        }
-        
-        protected void OnMessage(IMessage message)
-        {
-            Console.WriteLine("Received message: " + message);
-            lock (semaphore)
-            {
-                received = true;
-                Monitor.PulseAll(semaphore);
-            }
-            
-        }
-        
-        protected void WaitForMessageToArrive()
-        {
-            lock (semaphore)
-            {
-                if (!received)
+                protected Object semaphore = new Object();
+                protected bool received;
+
+                [ SetUp ]
+                override public void SetUp()
                 {
-                    Monitor.Wait(semaphore, receiveTimeout);
+                        base.SetUp();
                 }
-				Assert.AreEqual(true, received, "Should have received a message by now!");
-			}
-        }
-        
-    }
-}
 
+                [ TearDown ]
+                override public void TearDown()
+                {
+                        base.TearDown();
+                }
 
+                [ Test ]
+                public void TestAsynchronousConsume()
+                {
+
+                        // lets create an async consumer
+                        // START SNIPPET: demo
+                        IMessageConsumer consumer = Session.CreateConsumer(this.Destination);
+                        consumer.Listener += new MessageListener(OnMessage);
+                        // END SNIPPET: demo
+
+                        // now lets send a message
+                        IMessageProducer producer = CreateProducer();
+                        IMessage request = CreateMessage();
+                        request.NMSCorrelationID = "abc";
+                        request.NMSType = "Test";
+                        producer.Send(request);
+
+                        WaitForMessageToArrive();
+                }
+
+                [ Test ]
+                public void textMessageSRExample()
+                {
+                        using (IConnection connection = Factory.CreateConnection())
+                        {
+                                AcknowledgementMode acknowledgementMode = AcknowledgementMode.AutoAcknowledge;
+                                ISession session = connection.CreateSession(acknowledgementMode);
+
+                                IDestination destination = session.GetQueue("FOO.BAR");
+
+                                // lets create a consumer and producer
+                                IMessageConsumer consumer = session.CreateConsumer(destination);
+                                consumer.Listener += new MessageListener(OnMessage);
+
+                                IMessageProducer producer = session.CreateProducer(destination);
+                                producer.Persistent = true;
+
+                                // lets send a message
+                                ITextMessage request = session.CreateTextMessage(
+                                        "HelloWorld!");
+                                request.NMSCorrelationID = "abc";
+                                request.Properties["JMSXGroupID"] = "cheese";
+                                request.Properties["myHeader"] = "James";
+
+                                producer.Send(request);
+
+                                WaitForMessageToArrive();
+                        }
+                }
+
+                protected void OnMessage(IMessage message)
+                {
+                        Console.WriteLine("Received message: " + message);
+                        lock (semaphore)
+                        {
+                                received = true;
+                                Monitor.PulseAll(semaphore);
+                        }
+                }
+
+                protected void WaitForMessageToArrive()
+                {
+                        lock (semaphore)
+                        {
+                                if (!received)
+                                {
+                                        Monitor.Wait(semaphore, receiveTimeout);
+                                }
+                                Assert.AreEqual(true, received, "Should have received a message
by now!");
+                        }
+                }
+        }
+}



Mime
View raw message