This is an automated email from the ASF dual-hosted git repository.

havret pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-nms-api.git


The following commit(s) were added to refs/heads/main by this push:
     new 44c554f  AMQNET-846 Add option to customize acknowledgment behavior 
for expired messages via IRedeliveryPolicy
44c554f is described below

commit 44c554f6a73e88eb5441ce2c46c8949ff5ee81e2
Author: Havret <[email protected]>
AuthorDate: Sun May 25 22:29:28 2025 +0200

    AMQNET-846 Add option to customize acknowledgment behavior for expired 
messages via IRedeliveryPolicy
---
 src/nms-api/IRedeliveryPolicy.cs          | 28 ++++++++++++++++++++++++++++
 src/nms-api/policies/RedeliveryPolicy.cs  |  6 +++++-
 test/nms-api-test/RedeliveryPolicyTest.cs | 18 +++++++++++++-----
 3 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/src/nms-api/IRedeliveryPolicy.cs b/src/nms-api/IRedeliveryPolicy.cs
index 3cd636e..dc8e799 100644
--- a/src/nms-api/IRedeliveryPolicy.cs
+++ b/src/nms-api/IRedeliveryPolicy.cs
@@ -70,5 +70,33 @@ namespace Apache.NMS
         /// </summary>
         /// <value>The back off multiplier.</value>
         int BackOffMultiplier { get; set; }
+        
+        /// <summary>
+        /// Returns the provider-specific outcome code to use when a message 
is rejected by the client
+        /// after reaching the maximum redelivery threshold for the specified 
destination.
+        ///
+        /// The returned integer should map to an outcome defined by the 
specific provider implementation:
+        ///
+        /// For AMQP:
+        ///   0 - ACCEPTED  
+        ///   1 - REJECTED  
+        ///   2 - RELEASED  
+        ///   3 - MODIFIED_FAILED  
+        ///   4 - MODIFIED_UNDELIVERABLE_HERE
+        ///
+        /// For OpenWire:
+        ///   0 - DeliveredAck  
+        ///   1 - PoisonAck  
+        ///   2 - ConsumedAck  
+        ///   3 - RedeliveredAck  
+        ///   4 - IndividualAck  
+        ///   5 - UnmatchedAck  
+        ///   6 - ExpiredAck
+        ///
+        /// It is the responsibility of the provider to interpret the returned 
value appropriately.
+        /// </summary>
+        /// <param name="destination">The destination the message was received 
from.</param>
+        /// <returns>An integer representing the provider-specific outcome 
code.</returns>
+        int GetOutcode(IDestination destination);
     }
 }
\ No newline at end of file
diff --git a/src/nms-api/policies/RedeliveryPolicy.cs 
b/src/nms-api/policies/RedeliveryPolicy.cs
index 3d917d4..cd4cc53 100644
--- a/src/nms-api/policies/RedeliveryPolicy.cs
+++ b/src/nms-api/policies/RedeliveryPolicy.cs
@@ -22,7 +22,7 @@ namespace Apache.NMS.Policies
     /// <summary>
     /// A policy used to customize exactly how you want the redelivery to work.
     /// </summary>
-    public class RedeliveryPolicy : IRedeliveryPolicy
+    public abstract class RedeliveryPolicy : IRedeliveryPolicy
     {
         private static readonly object syncObject = new object();
 
@@ -104,6 +104,10 @@ namespace Apache.NMS.Policies
             set { backOffMultiplier = value; }
         }
 
+        
+        /// <inheritdoc />
+        public abstract int GetOutcode(IDestination destination);
+
         #endregion
 
         /// <summary>
diff --git a/test/nms-api-test/RedeliveryPolicyTest.cs 
b/test/nms-api-test/RedeliveryPolicyTest.cs
index 48dcdb8..f9e5873 100644
--- a/test/nms-api-test/RedeliveryPolicyTest.cs
+++ b/test/nms-api-test/RedeliveryPolicyTest.cs
@@ -26,7 +26,7 @@ namespace Apache.NMS.Test
         [Test]
         public void Executes_redelivery_policy_with_backoff_enabled_correctly()
         {
-            RedeliveryPolicy policy = new RedeliveryPolicy();
+            RedeliveryPolicy policy = new RedeliveryPolicyImpl();
 
             policy.BackOffMultiplier = 2;
             policy.InitialRedeliveryDelay = 5;
@@ -50,7 +50,7 @@ namespace Apache.NMS.Test
         [Test]
         public void 
Executes_redelivery_policy_with_backoff_of_3_enabled_correctly()
         {
-            RedeliveryPolicy policy = new RedeliveryPolicy();
+            RedeliveryPolicy policy = new RedeliveryPolicyImpl();
 
             policy.BackOffMultiplier = 3;
             policy.InitialRedeliveryDelay = 3;
@@ -75,7 +75,7 @@ namespace Apache.NMS.Test
         [Test]
         public void 
Executes_redelivery_policy_without_backoff_enabled_correctly()
         {
-            RedeliveryPolicy policy = new RedeliveryPolicy();
+            RedeliveryPolicy policy = new RedeliveryPolicyImpl();
 
             policy.InitialRedeliveryDelay = 5;
 
@@ -95,7 +95,7 @@ namespace Apache.NMS.Test
         [Test]
         public void Should_get_collision_percent_correctly()
         {
-            RedeliveryPolicy policy = new RedeliveryPolicy();
+            RedeliveryPolicy policy = new RedeliveryPolicyImpl();
 
             policy.CollisionAvoidancePercent = 45;
 
@@ -105,7 +105,7 @@ namespace Apache.NMS.Test
         [Test]
         public void 
Executes_redelivery_policy_with_collision_enabled_correctly()
         {
-            RedeliveryPolicy policy = new RedeliveryPolicy();
+            RedeliveryPolicy policy = new RedeliveryPolicyImpl();
 
             policy.BackOffMultiplier = 2;
             policy.InitialRedeliveryDelay = 5;
@@ -144,4 +144,12 @@ namespace Apache.NMS.Test
                 "not delay >= 2304 && delay <= 2816 is " + 
policy.RedeliveryDelay(10));
         }
     }
+
+    public class RedeliveryPolicyImpl : RedeliveryPolicy
+    {
+        public override int GetOutcode(IDestination destination)
+        {
+            throw new System.NotImplementedException();
+        }
+    }
 }
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to