You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2014/02/27 00:36:37 UTC
svn commit: r1572348 - in
/activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp:
BaseMessage.cs MapMessage.cs TextMessage.cs
Author: tabish
Date: Wed Feb 26 23:36:37 2014
New Revision: 1572348
URL: http://svn.apache.org/r1572348
Log:
https://issues.apache.org/jira/browse/AMQNET-454
applied:
https://issues.apache.org/jira/secure/attachment/12631369/Apache.NMS.AMQP-Add-message-cloning-19.patch
Modified:
activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/BaseMessage.cs
activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/MapMessage.cs
activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/TextMessage.cs
Modified: activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/BaseMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/BaseMessage.cs?rev=1572348&r1=1572347&r2=1572348&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/BaseMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/BaseMessage.cs Wed Feb 26 23:36:37 2014
@@ -22,15 +22,15 @@ namespace Apache.NMS.Amqp
{
public delegate void AcknowledgeHandler(BaseMessage baseMessage);
- public class BaseMessage : IMessage
+ public class BaseMessage : IMessage, ICloneable
{
private PrimitiveMap propertiesMap = new PrimitiveMap();
private IDestination destination;
private string correlationId;
private TimeSpan timeToLive;
private string messageId;
- private MsgDeliveryMode deliveryMode;
- private MsgPriority priority;
+ private MsgDeliveryMode deliveryMode = MsgDeliveryMode.NonPersistent;
+ private MsgPriority priority = MsgPriority.Normal;
private Destination replyTo;
private byte[] content;
private string type;
@@ -38,6 +38,177 @@ namespace Apache.NMS.Amqp
private DateTime timestamp = new DateTime();
private bool readOnlyMsgBody = false;
+ public BaseMessage() { }
+
+ public BaseMessage(BaseMessage copy)
+ {
+ this.propertiesMap = copy.propertiesMap;
+ this.destination = copy.destination;
+ this.correlationId = copy.correlationId;
+ this.timeToLive = copy.timeToLive;
+ this.messageId = copy.messageId;
+ this.deliveryMode = copy.deliveryMode;
+ this.priority = copy.priority;
+ this.replyTo = copy.replyTo;
+ this.content = copy.content;
+ this.type = copy.type;
+ this.Acknowledger = copy.Acknowledger;
+ this.timestamp = copy.timestamp;
+ this.readOnlyMsgBody = copy.readOnlyMsgBody;
+ }
+
+ ///
+ /// <summary>
+ /// Clone this object and return a new instance that the caller now owns.
+ /// </summary>
+ ///
+ public virtual Object Clone()
+ {
+ return this.MemberwiseClone();
+ }
+
+
+ public override bool Equals(object obj)
+ {
+ // If parameter is null return false.
+ if (obj == null)
+ {
+ return false;
+ }
+
+ // If parameter cannot be cast to BaseMessage return false.
+ BaseMessage p = obj as BaseMessage;
+ if ((System.Object)p == null)
+ {
+ return false;
+ }
+
+ if (propertiesMap == null ^ p.propertiesMap == null)
+ {
+ return false;
+ }
+ if (propertiesMap != null)
+ {
+ if (!propertiesMap.ToString().Equals(p.propertiesMap.ToString()))
+ {
+ return false;
+ }
+ }
+
+ if (destination == null ^ p.destination == null)
+ {
+ return false;
+ }
+ if (destination != null)
+ {
+ if (!destination.ToString().Equals(p.destination.ToString()))
+ {
+ return false;
+ }
+ }
+
+ if (correlationId == null ^ p.correlationId == null)
+ {
+ return false;
+ }
+ if (correlationId != null)
+ {
+ if (!correlationId.Equals(p.correlationId))
+ {
+ return false;
+ }
+ }
+
+ if (timeToLive == null ^ p.timeToLive == null)
+ {
+ return false;
+ }
+ if (timeToLive != null)
+ {
+ if (!timeToLive.ToString().Equals(p.timeToLive.ToString()))
+ {
+ return false;
+ }
+ }
+
+ if (messageId == null ^ p.messageId == null)
+ {
+ return false;
+ }
+ if (messageId != null)
+ {
+ if (!messageId.Equals(p.messageId))
+ {
+ return false;
+ }
+ }
+
+ if (deliveryMode != p.deliveryMode)
+ {
+ return false;
+ }
+
+ if (priority != p.priority)
+ {
+ return false;
+ }
+
+ if (replyTo == null ^ p.replyTo == null)
+ {
+ return false;
+ }
+ if (replyTo != null)
+ {
+ if (!replyTo.ToString().Equals(p.replyTo.ToString()))
+ {
+ return false;
+ }
+ }
+
+ if (content == null ^ p.content == null)
+ {
+ return false;
+ }
+ if (content != null)
+ {
+ if (!content.ToString().Equals(p.content.ToString()))
+ {
+ return false;
+ }
+ }
+
+ if (type == null ^ p.type == null)
+ {
+ return false;
+ }
+ if (type != null)
+ {
+ if (!type.Equals(p.type))
+ {
+ return false;
+ }
+ }
+
+ if (timestamp == null ^ p.timestamp == null)
+ {
+ return false;
+ }
+ if (timestamp != null)
+ {
+ if (!timestamp.ToString().Equals(p.timestamp.ToString()))
+ {
+ return false;
+ }
+ }
+
+ if (readOnlyMsgBody != p.readOnlyMsgBody)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
public bool ReadOnlyBody
{
get { return readOnlyMsgBody; }
Modified: activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/MapMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/MapMessage.cs?rev=1572348&r1=1572347&r2=1572348&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/MapMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/MapMessage.cs Wed Feb 26 23:36:37 2014
@@ -15,6 +15,7 @@
* limitations under the License.
*/
+using System.Collections.Generic;
using Apache.NMS.Util;
namespace Apache.NMS.Amqp
@@ -23,6 +24,16 @@ namespace Apache.NMS.Amqp
{
private IPrimitiveMap body = new PrimitiveMap();
+ public override object Clone()
+ {
+ MapMessage mm = (MapMessage)base.Clone();
+ DefaultMessageConverter msgConverter = new DefaultMessageConverter();
+ Dictionary<string, object> properties = new Dictionary<string, object>();
+ properties = msgConverter.FromNmsPrimitiveMap((PrimitiveMap)body);
+ msgConverter.SetNmsPrimitiveMap(mm.body, properties);
+ return (MapMessage)mm;
+ }
+
public IPrimitiveMap Body
{
get { return body; }
Modified: activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/TextMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/TextMessage.cs?rev=1572348&r1=1572347&r2=1572348&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/TextMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/TextMessage.cs Wed Feb 26 23:36:37 2014
@@ -34,6 +34,13 @@ namespace Apache.NMS.Amqp
this.Text = text;
}
+ public override object Clone()
+ {
+ TextMessage tm = (TextMessage) base.Clone();
+
+ tm.text = text;
+ return (TextMessage)tm;
+ }
// Properties