You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by js...@apache.org on 2006/10/18 13:44:02 UTC
svn commit: r465223 - in
/incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ:
MessageProducer.cs Util/DateUtils.cs
Author: jstrachan
Date: Wed Oct 18 04:44:01 2006
New Revision: 465223
URL: http://svn.apache.org/viewvc?view=rev&rev=465223
Log:
applied patch for AMQ-972 from Rob Lugt to fix the handling of NMSTimestamp
Added:
incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Util/DateUtils.cs
Modified:
incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/MessageProducer.cs
Modified: incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/MessageProducer.cs
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/MessageProducer.cs?view=diff&rev=465223&r1=465222&r2=465223
==============================================================================
--- incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/MessageProducer.cs (original)
+++ incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/MessageProducer.cs Wed Oct 18 04:44:01 2006
@@ -49,14 +49,24 @@
public void Send(IDestination destination, IMessage message)
{
- MessageId id = new MessageId();
- id.ProducerId = info.ProducerId;
- lock (this)
- {
- id.ProducerSequenceId = ++messageCounter;
- }
- ActiveMQMessage activeMessage = (ActiveMQMessage) message;
- activeMessage.MessageId = id;
+ ActiveMQMessage activeMessage = (ActiveMQMessage)message;
+
+ if (!disableMessageID)
+ {
+ MessageId id = new MessageId();
+ id.ProducerId = info.ProducerId;
+ lock (this)
+ {
+ id.ProducerSequenceId = ++messageCounter;
+ }
+ activeMessage.MessageId = id;
+ }
+
+ if (!disableMessageTimestamp)
+ {
+ activeMessage.Timestamp = ActiveMQ.Util.DateUtils.ToJavaTime(DateTime.UtcNow);
+ }
+
activeMessage.ProducerId = info.ProducerId;
activeMessage.Destination = ActiveMQDestination.Transform(destination);
Added: incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Util/DateUtils.cs
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Util/DateUtils.cs?view=auto&rev=465223
==============================================================================
--- incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Util/DateUtils.cs (added)
+++ incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Util/DateUtils.cs Wed Oct 18 04:44:01 2006
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+
+namespace ActiveMQ.Util
+{
+ internal class DateUtils
+ {
+ /// <summary>
+ /// The difference between the Windows epoch (1601-01-01 00:00:00)
+ /// and the Unix epoch (1970-01-01 00:00:00) in milliseconds.
+ /// </summary>
+ const long EPOCH_DIFF = 11644473600000L;
+
+ public static long ToJavaTime(DateTime dateTime)
+ {
+ return dateTime.ToFileTime() + EPOCH_DIFF;
+ }
+ }
+}