activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r678859 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp: Commands/ActiveMQMessage.cs MessageProducer.cs
Date Tue, 22 Jul 2008 18:43:34 GMT
Author: jgomes
Date: Tue Jul 22 11:43:34 2008
New Revision: 678859

URL: http://svn.apache.org/viewvc?rev=678859&view=rev
Log:
Refactor NMSTimeToLive.  There was a bug when setting the NMSTimeToLive value to 0.

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs?rev=678859&r1=678858&r2=678859&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs
Tue Jul 22 11:43:34 2008
@@ -36,8 +36,6 @@
         
         public event AcknowledgeHandler Acknowledger;
 
-		protected DateTime expirationBaseTime;
-        
         public static ActiveMQMessage Transform(IMessage message)
         {
             return (ActiveMQMessage) message;
@@ -54,7 +52,7 @@
         
         public void Acknowledge()
         {
-            if (Acknowledger == null)
+            if(null == Acknowledger)
 			{
                 throw new NMSException("No Acknowledger has been associated with this message:
" + this);
 			}
@@ -62,18 +60,19 @@
 			{
                 Acknowledger(this);
             }
-        }
-        
-        
-        // Properties
-        
-        public IPrimitiveMap Properties
+		}
+
+		#region Properties
+
+		public IPrimitiveMap Properties
         {
-            get {
-                if (properties == null)
+            get
+			{
+                if(null == properties)
                 {
                     properties = PrimitiveMap.Unmarshal(MarshalledProperties);
                 }
+
                 return properties;
             }
         }
@@ -89,12 +88,8 @@
         /// </summary>
         public string NMSCorrelationID
         {
-            get {
-                return CorrelationId;
-            }
-            set {
-                CorrelationId = value;
-            }
+            get { return CorrelationId; }
+            set { CorrelationId = value; }
         }
         
         /// <summary>
@@ -102,41 +97,41 @@
         /// </summary>
         public IDestination NMSDestination
         {
-            get {
-                return Destination;
-            }
+            get { return Destination; }
         }
-        
-        /// <summary>
+
+		private long expirationBaseTime = 0;
+		/// <summary>
         /// The time in milliseconds that this message should expire in
         /// </summary>
 		public TimeSpan NMSTimeToLive
 		{
-			get {
-				if(0 != Expiration)
+			get
+			{
+				return TimeSpan.FromMilliseconds(Expiration - expirationBaseTime);
+			}
+
+			set
+			{
+				if(0 != value.TotalMilliseconds)
 				{
-					DateTime expirationTime = DateUtils.ToDateTime(Expiration);
-					return expirationTime - expirationBaseTime;
+					expirationBaseTime = DateUtils.ToJavaTimeUtc(DateTime.UtcNow);
+					Expiration = expirationBaseTime + (long) Math.Abs(value.TotalMilliseconds);
 				}
 				else
 				{
-					return TimeSpan.FromMilliseconds(0);
+					expirationBaseTime = 0;
+					Expiration = 0;
 				}
 			}
-			set {
-				expirationBaseTime = DateTime.UtcNow;
-				Expiration = DateUtils.ToJavaTime(expirationBaseTime + value);
-			}
 		}
 
-        /// <summary>
+		/// <summary>
         /// The message ID which is set by the provider
         /// </summary>
         public string NMSMessageId
         {
-            get {
-                return BaseDataStreamMarshaller.ToString(MessageId);
-            }
+            get { return BaseDataStreamMarshaller.ToString(MessageId); }
         }
         
         /// <summary>
@@ -144,12 +139,8 @@
         /// </summary>
         public bool NMSPersistent
         {
-            get {
-                return Persistent;
-            }
-            set {
-                Persistent = value;
-            }
+            get { return Persistent; }
+            set { Persistent = value; }
         }
         
         /// <summary>
@@ -157,12 +148,8 @@
         /// </summary>
         public byte NMSPriority
         {
-            get {
-                return Priority;
-            }
-            set {
-                Priority = value;
-            }
+            get { return Priority; }
+            set { Priority = value; }
         }
         
         /// <summary>
@@ -170,37 +157,25 @@
         /// </summary>
         public bool NMSRedelivered
         {
-            get {
-                return RedeliveryCounter > 0;
-            }
+            get { return (RedeliveryCounter > 0); }
         }
         
-        
         /// <summary>
         /// The destination that the consumer of this message should send replies to
         /// </summary>
         public IDestination NMSReplyTo
         {
-            get {
-                return ReplyTo;
-            }
-            set {
-                ReplyTo = ActiveMQDestination.Transform(value);
-            }
+            get { return ReplyTo; }
+            set { ReplyTo = ActiveMQDestination.Transform(value); }
         }
         
-        
         /// <summary>
         /// The timestamp the broker added to the message
         /// </summary>
         public DateTime NMSTimestamp
         {
-            get {
-                return DateUtils.ToDateTime(Timestamp);
-            }
-            set {
-                Timestamp = DateUtils.ToJavaTime(value);
-            }
+            get { return DateUtils.ToDateTime(Timestamp); }
+            set { Timestamp = DateUtils.ToJavaTimeUtc(value); }
         }
         
         /// <summary>
@@ -208,51 +183,37 @@
         /// </summary>
         public string NMSType
         {
-            get {
-                return Type;
-            }
-            set {
-                Type = value;
-            }
-        }
-        
-        
-        // NMS Extension headers
-        
-        /// <summary>
+            get { return Type; }
+            set { Type = value; }
+		}
+
+		#endregion
+
+		#region NMS Extension headers
+
+		/// <summary>
         /// Returns the number of times this message has been redelivered to other consumers
without being acknowledged successfully.
         /// </summary>
         public int NMSXDeliveryCount
         {
-            get {
-                return RedeliveryCounter + 1;
-            }
+            get { return RedeliveryCounter + 1; }
         }
         
-        
         /// <summary>
         /// The Message Group ID used to group messages together to the same consumer for
the same group ID value
         /// </summary>
         public string NMSXGroupID
         {
-            get {
-                return GroupID;
-            }
-            set {
-                GroupID = value;
-            }
+            get { return GroupID; }
+            set { GroupID = value; }
         }
         /// <summary>
         /// The Message Group Sequence counter to indicate the position in a group
         /// </summary>
         public int NMSXGroupSeq
         {
-            get {
-                return GroupSequence;
-            }
-            set {
-                GroupSequence = value;
-            }
+            get { return GroupSequence; }
+            set { GroupSequence = value; }
         }
         
         /// <summary>
@@ -260,21 +221,26 @@
         /// </summary>
         public string NMSXProducerTXID
         {
-            get {
+            get
+			{
                 TransactionId txnId = OriginalTransactionId;
-                if (txnId == null)
+                if(null == txnId)
                 {
                     txnId = TransactionId;
                 }
-                if (txnId != null)
+
+                if(null != txnId)
                 {
                     return BaseDataStreamMarshaller.ToString(txnId);
                 }
+
                 return null;
             }
-        }
-        
-        public object GetObjectProperty(string name)
+		}
+
+		#endregion
+
+		public object GetObjectProperty(string name)
         {
             return propertyHelper.GetObjectProperty(this, name);
         }
@@ -298,8 +264,6 @@
                 MarshalledProperties = properties.Marshal();
             }
         }
-        
-        
     }
 }
 

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs?rev=678859&r1=678858&r2=678859&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
Tue Jul 22 11:43:34 2008
@@ -161,14 +161,14 @@
 				activeMessage.TransactionId = session.TransactionContext.TransactionId;
 			}
 
-			if (specifiedTimeToLive)
+			if (!disableMessageTimestamp)
 			{
-				activeMessage.NMSTimeToLive = timeToLive;
+				activeMessage.NMSTimestamp = DateTime.UtcNow;
 			}
 
-			if (!disableMessageTimestamp)
+			if(specifiedTimeToLive)
 			{
-				activeMessage.NMSTimestamp = DateTime.UtcNow;
+				activeMessage.NMSTimeToLive = timeToLive;
 			}
 
 			session.DoSend(activeMessage);



Mime
View raw message