activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michaelpea...@apache.org
Subject [activemq-nms-amqp] branch master updated: AMQNET-599: Changing Message NMSDeliveryMode property should set Amqp.Message Header durable field
Date Mon, 12 Aug 2019 13:26:12 GMT
This is an automated email from the ASF dual-hosted git repository.

michaelpearce pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-nms-amqp.git


The following commit(s) were added to refs/heads/master by this push:
     new d5796a8  AMQNET-599: Changing Message NMSDeliveryMode property should set Amqp.Message
Header durable field
     new 5a71589  Merge pull request #18 from Havret/AMQNET-599
d5796a8 is described below

commit d5796a8d9b97c6b8f83b38ced1fa10465eeb4031
Author: Havret <h4vret@gmail.com>
AuthorDate: Sat Aug 10 19:20:56 2019 +0200

    AMQNET-599: Changing Message NMSDeliveryMode property should set Amqp.Message Header durable
field
    
    (cherry picked from commit 3ce0c9779093e4c3db467d0e81ef190d42d7c31b)
---
 src/NMS.AMQP/Message/Facade/INmsMessageFacade.cs       |  7 ++++++-
 src/NMS.AMQP/Message/NmsMessage.cs                     | 18 ++++++++++++++++--
 .../Provider/Amqp/Message/AmqpNmsMessageFacade.cs      |  8 ++++++--
 .../Message/Facade/NmsTestMessageFacade.cs             |  3 ++-
 .../Provider/Amqp/AmqpNmsMessageFacadeTest.cs          |  4 ++--
 5 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/src/NMS.AMQP/Message/Facade/INmsMessageFacade.cs b/src/NMS.AMQP/Message/Facade/INmsMessageFacade.cs
index 34bffd9..f610a6f 100644
--- a/src/NMS.AMQP/Message/Facade/INmsMessageFacade.cs
+++ b/src/NMS.AMQP/Message/Facade/INmsMessageFacade.cs
@@ -30,7 +30,6 @@ namespace Apache.NMS.AMQP.Message.Facade
         string NMSCorrelationID { get; set; }
         IDestination NMSDestination { get; set; }
         TimeSpan NMSTimeToLive { get; set; }
-        MsgDeliveryMode NMSDeliveryMode { get; set; }
         MsgPriority NMSPriority { get; set; }
         bool NMSRedelivered { get; set; }
         IDestination NMSReplyTo { get; set; }
@@ -40,6 +39,12 @@ namespace Apache.NMS.AMQP.Message.Facade
         uint GroupSequence { get; set; }
         DateTime Expiration { get; set; }
         sbyte JmsMsgType { get; }
+        
+        /// <summary>
+        /// True if this message is tagged as being persistent
+        /// </summary>
+        bool IsPersistent { get; set; }
+        
         INmsMessageFacade Copy();
     }
 }
\ No newline at end of file
diff --git a/src/NMS.AMQP/Message/NmsMessage.cs b/src/NMS.AMQP/Message/NmsMessage.cs
index 9f9c1c9..c8cba84 100644
--- a/src/NMS.AMQP/Message/NmsMessage.cs
+++ b/src/NMS.AMQP/Message/NmsMessage.cs
@@ -61,8 +61,22 @@ namespace Apache.NMS.AMQP.Message
 
         public MsgDeliveryMode NMSDeliveryMode
         {
-            get => Facade.NMSDeliveryMode;
-            set => Facade.NMSDeliveryMode = value;
+            get => Facade.IsPersistent ? MsgDeliveryMode.Persistent : MsgDeliveryMode.NonPersistent;
+            set
+            {
+                CheckReadOnly();
+                switch (value)
+                {
+                    case MsgDeliveryMode.Persistent:
+                        Facade.IsPersistent = true;
+                        break;
+                    case MsgDeliveryMode.NonPersistent:
+                        Facade.IsPersistent = false;
+                        break;
+                    default:
+                        throw new NMSException($"Invalid DeliveryMode specified: {value}");
+                }
+            }
         }
 
         public MsgPriority NMSPriority
diff --git a/src/NMS.AMQP/Provider/Amqp/Message/AmqpNmsMessageFacade.cs b/src/NMS.AMQP/Provider/Amqp/Message/AmqpNmsMessageFacade.cs
index 8e14526..29ec18c 100644
--- a/src/NMS.AMQP/Provider/Amqp/Message/AmqpNmsMessageFacade.cs
+++ b/src/NMS.AMQP/Provider/Amqp/Message/AmqpNmsMessageFacade.cs
@@ -158,8 +158,12 @@ namespace Apache.NMS.AMQP.Provider.Amqp.Message
             get => amqpTimeToLiveOverride ?? TimeSpan.FromMilliseconds(Header.Ttl);
             set => amqpTimeToLiveOverride = value;
         }
-
-        public MsgDeliveryMode NMSDeliveryMode { get; set; }
+        
+        public bool IsPersistent
+        {
+            get => Message.Header.Durable;
+            set => Message.Header.Durable = value;
+        }
 
         public MsgPriority NMSPriority
         {
diff --git a/test/Apache-NMS-AMQP-Test/Message/Facade/NmsTestMessageFacade.cs b/test/Apache-NMS-AMQP-Test/Message/Facade/NmsTestMessageFacade.cs
index 4f04440..d7f3e09 100644
--- a/test/Apache-NMS-AMQP-Test/Message/Facade/NmsTestMessageFacade.cs
+++ b/test/Apache-NMS-AMQP-Test/Message/Facade/NmsTestMessageFacade.cs
@@ -67,7 +67,6 @@ namespace NMS.AMQP.Test.Message.Facade
         public string NMSCorrelationID { get; set; }
         public IDestination NMSDestination { get; set; }
         public TimeSpan NMSTimeToLive { get; set; }
-        public MsgDeliveryMode NMSDeliveryMode { get; set; }
         public MsgPriority NMSPriority { get; set; }
         public bool NMSRedelivered { get; set; }
         public IDestination NMSReplyTo { get; set; }
@@ -77,6 +76,8 @@ namespace NMS.AMQP.Test.Message.Facade
         public uint GroupSequence { get; set; }
         public DateTime Expiration { get; set; }
         public sbyte JmsMsgType { get; }
+        public bool IsPersistent { get; set; }
+
         public INmsMessageFacade Copy()
         {
             return null;
diff --git a/test/Apache-NMS-AMQP-Test/Provider/Amqp/AmqpNmsMessageFacadeTest.cs b/test/Apache-NMS-AMQP-Test/Provider/Amqp/AmqpNmsMessageFacadeTest.cs
index 8bc878a..0da7b33 100644
--- a/test/Apache-NMS-AMQP-Test/Provider/Amqp/AmqpNmsMessageFacadeTest.cs
+++ b/test/Apache-NMS-AMQP-Test/Provider/Amqp/AmqpNmsMessageFacadeTest.cs
@@ -1330,7 +1330,7 @@ namespace NMS.AMQP.Test.Provider.Amqp
             source.NMSMessageId = "ID:TEST-MESSAGEID";
             source.NMSPriority = MsgPriority.High;
             source.RedeliveryCount = 12;
-            source.NMSDeliveryMode = MsgDeliveryMode.Persistent;
+            source.IsPersistent = true;
             source.NMSTimestamp = DateTime.UtcNow;
             source.NMSTimeToLive = TimeSpan.FromDays(1);
             source.UserId = "Cookie-Monster";
@@ -1349,7 +1349,7 @@ namespace NMS.AMQP.Test.Provider.Amqp
             Assert.AreEqual(source.NMSMessageId, copy.NMSMessageId);
             Assert.AreEqual(source.NMSPriority, copy.NMSPriority);
             Assert.AreEqual(source.RedeliveryCount, copy.RedeliveryCount);
-            Assert.AreEqual(source.NMSDeliveryMode, copy.NMSDeliveryMode);
+            Assert.AreEqual(source.IsPersistent, copy.IsPersistent);
             Assert.AreEqual(source.UserId, copy.UserId);
             Assert.AreEqual(source.NMSTimeToLive, copy.NMSTimeToLive);
             Assert.IsTrue(Math.Abs((copy.Expiration - source.Expiration).TotalMilliseconds)
< 1);


Mime
View raw message