activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [42/50] [abbrv] activemq-nms-openwire git commit: Ensure that the message body is always marshaled. Fixes case of a single message -> receive -> send -> receive which would lose its body on the re-send.
Date Wed, 08 Mar 2017 23:12:44 GMT
Ensure that the message body is always marshaled.  Fixes case of a single message -> receive
-> send -> receive which would lose its body on the re-send.  

AMQNET-514
Fixes [AMQNET-AMQNET-514]. (See https://issues.apache.org/jira/browse/AMQNET-AMQNET-514)



Project: http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/commit/d091a999
Tree: http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/tree/d091a999
Diff: http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/diff/d091a999

Branch: refs/heads/1.7.x
Commit: d091a999ee25c0143d5c9b48394a18444d8fc639
Parents: 62b0c95
Author: Timothy A. Bish <tabish@apache.org>
Authored: Tue Jan 5 17:21:24 2016 +0000
Committer: Timothy A. Bish <tabish@apache.org>
Committed: Tue Jan 5 17:21:24 2016 +0000

----------------------------------------------------------------------
 src/main/csharp/Commands/ActiveMQMapMessage.cs  |  6 +--
 .../csharp/Commands/ActiveMQMapMessageTest.cs   | 53 ++++++++++++++++++--
 2 files changed, 49 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/blob/d091a999/src/main/csharp/Commands/ActiveMQMapMessage.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/Commands/ActiveMQMapMessage.cs b/src/main/csharp/Commands/ActiveMQMapMessage.cs
index 7bdebdf..2b9a057 100644
--- a/src/main/csharp/Commands/ActiveMQMapMessage.cs
+++ b/src/main/csharp/Commands/ActiveMQMapMessage.cs
@@ -91,11 +91,7 @@ namespace Apache.NMS.ActiveMQ.Commands
 
 		public override void BeforeMarshall(OpenWireFormat wireFormat)
 		{
-			if(body == null)
-			{
-				Content = null;
-			}
-			else
+            if (this.Content == null && this.body != null && this.body.Count
> 0)
 			{
 				MemoryStream buffer = new MemoryStream();
 				Stream target = buffer;

http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/blob/d091a999/src/test/csharp/Commands/ActiveMQMapMessageTest.cs
----------------------------------------------------------------------
diff --git a/src/test/csharp/Commands/ActiveMQMapMessageTest.cs b/src/test/csharp/Commands/ActiveMQMapMessageTest.cs
index 016822f..ecde5a6 100644
--- a/src/test/csharp/Commands/ActiveMQMapMessageTest.cs
+++ b/src/test/csharp/Commands/ActiveMQMapMessageTest.cs
@@ -19,15 +19,17 @@ using System;
 using System.Collections;
 using System.Globalization;
 using System.Text;
+using Apache.NMS;
+using Apache.NMS.Test;
+using Apache.NMS.Util;
 using Apache.NMS.ActiveMQ.Commands;
 using NUnit.Framework;
 
 namespace Apache.NMS.ActiveMQ.Test.Commands
 {    
     [TestFixture]
-    public class ActiveMQMapMessageTest
+    public class ActiveMQMapMessageTest : NMSTestSupport
     {
-
         private string name = "testName";
         
         [Test]
@@ -305,7 +307,6 @@ namespace Apache.NMS.ActiveMQ.Test.Commands
             catch(MessageFormatException)
             {
             }
-    
         }
     
         [Test]
@@ -457,7 +458,8 @@ namespace Apache.NMS.ActiveMQ.Test.Commands
             {
             }
             
-            try {
+            try 
+            {
                 msg.Body.SetFloat("float", 1.5f);
                 Assert.Fail("should throw exception");
             } 
@@ -543,6 +545,47 @@ namespace Apache.NMS.ActiveMQ.Test.Commands
             msg.Body.GetShort("short");
             msg.Body.GetString("string");
         }
-        
+
+        [Test]
+        public void TestMessageQueueDequeQueueDequeue()
+        {
+            using (IConnection connection = CreateConnection())
+            using (ISession session = connection.CreateSession())
+            {
+                IDestination destination = session.GetQueue("TestMessageQueueDequeQueueDequeue");
+
+                (connection as Connection).DeleteDestination(destination);
+
+                using (IMessageConsumer consumer = session.CreateConsumer(destination))
+                using (IMessageProducer producer = session.CreateProducer(destination))
+                {
+                    connection.Start();
+
+                    producer.DeliveryMode = MsgDeliveryMode.Persistent;
+
+                    IMapMessage request = session.CreateMapMessage();
+                    request.Body.SetString("Unit-Test-Key", "Unit-Test-Value");
+                    Assert.IsNotNull(request, "request is null");
+                    Assert.IsTrue(request.Body.Contains("Unit-Test-Key"), "Unit-Test-Key
does not exist");
+                    producer.Send(request);
+
+                    // Relay from Queue back again.
+                    IMessage received = consumer.Receive(TimeSpan.FromSeconds(2));
+                    Assert.IsNotNull(received);
+                    IMapMessage mapMessage = received as IMapMessage;
+                    Assert.IsNotNull(mapMessage);
+                    producer.Send(mapMessage);
+
+                    // Read it again and validate.
+                    received = consumer.Receive(TimeSpan.FromSeconds(2));
+                    Assert.IsNotNull(received);
+                    mapMessage = received as IMapMessage;
+                    Assert.IsNotNull(mapMessage, "currentMessage is null");
+
+                    // This entry in the map message should not be removed
+                    Assert.IsTrue(mapMessage.Body.Contains("Unit-Test-Key"), "Unit-Test-Key
does not exist");
+                }
+            }
+        }
     }
 }


Mime
View raw message