From 4ae54fe77b7b30227c6380aae84cbd3045ea417b Mon Sep 17 00:00:00 2001 From: markpollack Date: Tue, 16 Jun 2009 20:02:46 +0000 Subject: [PATCH] SPRNET-1218 - Update to use Apache NMS 1.1 --- .../Nms/Connections/CachedMessageProducer.cs | 31 +++++++-------- .../Messaging/Nms/Core/NmsTemplate.cs | 38 ++++++++++++++----- .../Nms/Connections/TestMessageProducer.cs | 16 ++++---- 3 files changed, 52 insertions(+), 33 deletions(-) diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachedMessageProducer.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachedMessageProducer.cs index a25051f1..e398fde3 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachedMessageProducer.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachedMessageProducer.cs @@ -37,9 +37,9 @@ namespace Spring.Messaging.Nms.Connections private object originalDisableMessageTimestamp = null; - private bool persistent; + private MsgDeliveryMode msgDeliveryMode; - private byte priority; + private MsgPriority priority; private TimeSpan timeToLive; @@ -53,7 +53,7 @@ namespace Spring.Messaging.Nms.Connections public CachedMessageProducer(IMessageProducer target) { this.target = target; - this.persistent = target.Persistent; + this.msgDeliveryMode = target.DeliveryMode; this.priority = target.Priority; this.timeToLive = target.TimeToLive; } @@ -81,12 +81,12 @@ namespace Spring.Messaging.Nms.Connections /// Sends a message to the specified message. /// /// The message to send. - /// if set to true use persistent QOS. + /// The QOS to use for sending . /// The message priority. /// The time to live. - public void Send(IMessage message, bool persistent, byte priority, TimeSpan timeToLive) + public void Send(IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive) { - target.Send(message, persistent, priority, timeToLive); + target.Send(message, deliveryMode, priority, timeToLive); } /// @@ -104,12 +104,12 @@ namespace Spring.Messaging.Nms.Connections /// /// The destination. /// The message to send. - /// if set to true use persistent QOS. + /// The QOS to use for sending . /// The priority. /// The time to live. - public void Send(IDestination destination, IMessage message, bool persistent, byte priority, TimeSpan timeToLive) + public void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive) { - target.Send(destination, message, persistent, priority, timeToLive); + target.Send(destination, message, deliveryMode, priority, timeToLive); } #region Odd Message Creationg Methods on IMessageProducer - not in-line with JMS APIs. @@ -181,13 +181,14 @@ namespace Spring.Messaging.Nms.Connections #endregion /// - /// Gets or sets a value indicating whether this uses a persistent QOS + /// Gets or sets a value indicating what DeliveryMode this + /// should use, for example a persistent QOS /// - /// true if persistent; otherwise, false. - public bool Persistent + /// + public MsgDeliveryMode DeliveryMode { - get { return persistent; } - set { persistent = value; } + get { return msgDeliveryMode; } + set { msgDeliveryMode = value; } } /// @@ -215,7 +216,7 @@ namespace Spring.Messaging.Nms.Connections /// Gets or sets the priority of messages sent with this producer. /// /// The priority. - public byte Priority + public MsgPriority Priority { get { return priority; } set { priority = value;} diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTemplate.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTemplate.cs index 458b0027..e138cf01 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTemplate.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTemplate.cs @@ -80,12 +80,12 @@ namespace Spring.Messaging.Nms.Core private bool explicitQosEnabled = false; - private byte priority = NMSConstants.defaultPriority; - - private bool persistent = NMSConstants.defaultPersistence; - - private TimeSpan timeToLive; - + private MsgPriority priority = NMSConstants.defaultPriority; + + private TimeSpan timeToLive; + + private MsgDeliveryMode deliveryMode = NMSConstants.defaultDeliveryMode; + #endregion #region Constructor (s) @@ -319,9 +319,27 @@ namespace Spring.Messaging.Nms.Core /// true if [delivery persistent]; otherwise, false. virtual public bool Persistent { - get { return persistent; } + get { return (deliveryMode == MsgDeliveryMode.Persistent); } - set { persistent = value; } + set + { + if (value) { + deliveryMode = MsgDeliveryMode.Persistent; + } else { + deliveryMode = MsgDeliveryMode.NonPersistent; + } + } + } + + /// + /// Gets or sets a value indicating what DeliveryMode this + /// should use, for example a persistent QOS + /// + /// + virtual public MsgDeliveryMode DeliveryMode + { + get { return deliveryMode; } + set { deliveryMode = value; } } /// @@ -330,7 +348,7 @@ namespace Spring.Messaging.Nms.Core /// Since a default value may be defined administratively, /// this is only used when "isExplicitQosEnabled" equals "true". /// The priority. - virtual public byte Priority + virtual public MsgPriority Priority { get { return priority; } @@ -568,7 +586,7 @@ namespace Spring.Messaging.Nms.Core { if (ExplicitQosEnabled) { - producer.Send(message, Persistent, Priority, TimeToLive); + producer.Send(message, DeliveryMode, Priority, TimeToLive); } else { diff --git a/test/Spring/Spring.Messaging.Nms.Tests/Messaging/Nms/Connections/TestMessageProducer.cs b/test/Spring/Spring.Messaging.Nms.Tests/Messaging/Nms/Connections/TestMessageProducer.cs index 92b73667..ecc77dec 100644 --- a/test/Spring/Spring.Messaging.Nms.Tests/Messaging/Nms/Connections/TestMessageProducer.cs +++ b/test/Spring/Spring.Messaging.Nms.Tests/Messaging/Nms/Connections/TestMessageProducer.cs @@ -26,7 +26,7 @@ namespace Spring.Messaging.Nms.Connections public class TestMessageProducer : IMessageProducer { - private bool persistent; + private MsgDeliveryMode msgDeliveryMode; private TimeSpan timeToLive = new TimeSpan(0,0,0,60,0); private TimeSpan requestTimeout; @@ -35,7 +35,7 @@ namespace Spring.Messaging.Nms.Connections throw new NotImplementedException(); } - public void Send(IMessage message, bool persistent, byte priority, TimeSpan timeToLive) + public void Send(IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive) { throw new NotImplementedException(); } @@ -45,7 +45,7 @@ namespace Spring.Messaging.Nms.Connections throw new NotImplementedException(); } - public void Send(IDestination destination, IMessage message, bool persistent, byte priority, TimeSpan timeToLive) + public void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive) { throw new NotImplementedException(); } @@ -90,10 +90,10 @@ namespace Spring.Messaging.Nms.Connections throw new NotImplementedException(); } - public bool Persistent + public MsgDeliveryMode DeliveryMode { - get { return persistent; } - set { persistent = value; } + get { return msgDeliveryMode; } + set { msgDeliveryMode = value; } } public TimeSpan TimeToLive @@ -108,9 +108,9 @@ namespace Spring.Messaging.Nms.Connections set { requestTimeout = value; } } - public byte Priority + public MsgPriority Priority { - get { return 1; } + get { return MsgPriority.Normal; } set { } }