Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 60877 invoked from network); 22 Jul 2008 18:44:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Jul 2008 18:44:26 -0000 Received: (qmail 24937 invoked by uid 500); 22 Jul 2008 18:44:25 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 24918 invoked by uid 500); 22 Jul 2008 18:44:25 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 24909 invoked by uid 99); 22 Jul 2008 18:44:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jul 2008 11:44:25 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jul 2008 18:43:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0AA042388987; Tue, 22 Jul 2008 11:43:35 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@activemq.apache.org From: jgomes@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080722184335.0AA042388987@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ /// public string NMSCorrelationID { - get { - return CorrelationId; - } - set { - CorrelationId = value; - } + get { return CorrelationId; } + set { CorrelationId = value; } } /// @@ -102,41 +97,41 @@ /// public IDestination NMSDestination { - get { - return Destination; - } + get { return Destination; } } - - /// + + private long expirationBaseTime = 0; + /// /// The time in milliseconds that this message should expire in /// 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); - } } - /// + /// /// The message ID which is set by the provider /// public string NMSMessageId { - get { - return BaseDataStreamMarshaller.ToString(MessageId); - } + get { return BaseDataStreamMarshaller.ToString(MessageId); } } /// @@ -144,12 +139,8 @@ /// public bool NMSPersistent { - get { - return Persistent; - } - set { - Persistent = value; - } + get { return Persistent; } + set { Persistent = value; } } /// @@ -157,12 +148,8 @@ /// public byte NMSPriority { - get { - return Priority; - } - set { - Priority = value; - } + get { return Priority; } + set { Priority = value; } } /// @@ -170,37 +157,25 @@ /// public bool NMSRedelivered { - get { - return RedeliveryCounter > 0; - } + get { return (RedeliveryCounter > 0); } } - /// /// The destination that the consumer of this message should send replies to /// public IDestination NMSReplyTo { - get { - return ReplyTo; - } - set { - ReplyTo = ActiveMQDestination.Transform(value); - } + get { return ReplyTo; } + set { ReplyTo = ActiveMQDestination.Transform(value); } } - /// /// The timestamp the broker added to the message /// public DateTime NMSTimestamp { - get { - return DateUtils.ToDateTime(Timestamp); - } - set { - Timestamp = DateUtils.ToJavaTime(value); - } + get { return DateUtils.ToDateTime(Timestamp); } + set { Timestamp = DateUtils.ToJavaTimeUtc(value); } } /// @@ -208,51 +183,37 @@ /// public string NMSType { - get { - return Type; - } - set { - Type = value; - } - } - - - // NMS Extension headers - - /// + get { return Type; } + set { Type = value; } + } + + #endregion + + #region NMS Extension headers + + /// /// Returns the number of times this message has been redelivered to other consumers without being acknowledged successfully. /// public int NMSXDeliveryCount { - get { - return RedeliveryCounter + 1; - } + get { return RedeliveryCounter + 1; } } - /// /// The Message Group ID used to group messages together to the same consumer for the same group ID value /// public string NMSXGroupID { - get { - return GroupID; - } - set { - GroupID = value; - } + get { return GroupID; } + set { GroupID = value; } } /// /// The Message Group Sequence counter to indicate the position in a group /// public int NMSXGroupSeq { - get { - return GroupSequence; - } - set { - GroupSequence = value; - } + get { return GroupSequence; } + set { GroupSequence = value; } } /// @@ -260,21 +221,26 @@ /// 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);