activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r1509366 - in /activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp: BytesMessage.cs Dispatcher.cs MapMessage.cs Message.cs MessageProducer.cs
Date Thu, 01 Aug 2013 18:21:21 GMT
Author: jgomes
Date: Thu Aug  1 18:21:21 2013
New Revision: 1509366

URL: http://svn.apache.org/r1509366
Log:
Fix the message properties to use the MessagePropertyIntercepter to correctly set the custom
NMS properties.
Ported ReadOnlyProperties flag from ActiveMQ client.

Modified:
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/BytesMessage.cs
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Dispatcher.cs
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MapMessage.cs
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Message.cs
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MessageProducer.cs

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/BytesMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/BytesMessage.cs?rev=1509366&r1=1509365&r2=1509366&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/BytesMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/BytesMessage.cs Thu Aug
 1 18:21:21 2013
@@ -46,6 +46,7 @@ namespace Apache.NMS.EMS
 
 			set
 			{
+				this.ReadOnlyBody = false;
 				this.tibcoBytesMessage.ClearBody();
 				this.tibcoBytesMessage.WriteBytes(value, 0, value.Length);
 			}

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Dispatcher.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Dispatcher.cs?rev=1509366&r1=1509365&r2=1509366&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Dispatcher.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Dispatcher.cs Thu Aug  1
18:21:21 2013
@@ -103,12 +103,17 @@ namespace Apache.NMS.EMS
         /// </summary>
 		public Apache.NMS.IMessage DequeueNoWait()
         {
-			Apache.NMS.IMessage rc = null;
+			Apache.NMS.EMS.Message rc = null;
             lock (semaphore)
             {
                 if (!m_bClosed && queue.Count > 0)
                 {
-					rc = (Apache.NMS.IMessage) queue.Dequeue();
+					rc = (Apache.NMS.EMS.Message) queue.Dequeue();
+					if(null != rc)
+					{
+						rc.ReadOnlyBody = true;
+						rc.ReadOnlyProperties = true;
+					}
                 } 
             }
             return rc;

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MapMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MapMessage.cs?rev=1509366&r1=1509365&r2=1509366&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MapMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MapMessage.cs Thu Aug  1
18:21:21 2013
@@ -48,6 +48,7 @@ namespace Apache.NMS.EMS
 		{
 			try
 			{
+				this.ReadOnlyBody = false;
 				this.tibcoMapMessage.ClearBody();
 			}
 			catch(Exception ex)

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Message.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Message.cs?rev=1509366&r1=1509365&r2=1509366&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Message.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Message.cs Thu Aug  1 18:21:21
2013
@@ -21,6 +21,11 @@ namespace Apache.NMS.EMS
 {
 	class Message : Apache.NMS.IMessage
 	{
+		private Apache.NMS.IPrimitiveMap properties = null;
+		private Apache.NMS.Util.MessagePropertyIntercepter propertyHelper;
+		private bool readOnlyMsgProperties = false;
+		private bool readOnlyMsgBody = false;
+
 		public TIBCO.EMS.Message tibcoMessage;
 
 		public Message(TIBCO.EMS.Message message)
@@ -57,6 +62,7 @@ namespace Apache.NMS.EMS
 		{
 			try
 			{
+				this.ReadOnlyBody = false;
 				this.tibcoMessage.ClearBody();
 			}
 			catch(Exception ex)
@@ -74,6 +80,7 @@ namespace Apache.NMS.EMS
 		{
 			try
 			{
+				this.ReadOnlyProperties = false;
 				this.tibcoMessage.ClearProperties();
 			}
 			catch(Exception ex)
@@ -82,12 +89,44 @@ namespace Apache.NMS.EMS
 			}
 		}
 
+		public virtual bool ReadOnlyBody
+		{
+			get { return this.readOnlyMsgBody; }
+			set { this.readOnlyMsgBody = value; }
+		}
+
+		public virtual bool ReadOnlyProperties
+		{
+			get { return this.readOnlyMsgProperties; }
+
+			set
+			{
+				if(this.propertyHelper != null)
+				{
+					this.propertyHelper.ReadOnly = value;
+				}
+				this.readOnlyMsgProperties = value;
+			}
+		}
+
 		/// <summary>
 		/// Provides access to the message properties (headers)
 		/// </summary>
 		public Apache.NMS.IPrimitiveMap Properties
 		{
-			get { return EMSConvert.ToMessageProperties(this.tibcoMessage); }
+			get
+			{
+				if(null == properties)
+				{
+					properties = EMSConvert.ToMessageProperties(this.tibcoMessage);
+					propertyHelper = new Apache.NMS.Util.MessagePropertyIntercepter(this, properties, this.ReadOnlyProperties)
{ AllowByteArrays = false };
+
+					// Since JMS doesn't define a Byte array interface for properties we
+					// disable them here to prevent sending invalid data to the broker.
+				}
+
+				return propertyHelper;
+			}
 		}
 
 		/// <summary>
@@ -256,5 +295,15 @@ namespace Apache.NMS.EMS
 		}
 
 		#endregion
+
+		public virtual void OnSend()
+		{
+			this.ReadOnlyProperties = true;
+			this.ReadOnlyBody = true;
+		}
+
+		public virtual void OnMessageRollback()
+		{
+		}
 	}
 }

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MessageProducer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MessageProducer.cs?rev=1509366&r1=1509365&r2=1509366&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MessageProducer.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MessageProducer.cs Thu Aug
 1 18:21:21 2013
@@ -73,6 +73,7 @@ namespace Apache.NMS.EMS
 
 			try
 			{
+				msg.OnSend();
 				this.tibcoMessageProducer.Send(
 							msg.tibcoMessage,
 							this.tibcoMessageProducer.MsgDeliveryMode,



Mime
View raw message