diff options
| author | Tomas Restrepo <tomasr@apache.org> | 2007-05-18 00:51:12 +0000 |
|---|---|---|
| committer | Tomas Restrepo <tomasr@apache.org> | 2007-05-18 00:51:12 +0000 |
| commit | dbe349500e458cdf38cd4e561d27c9fa24dff7ca (patch) | |
| tree | 2390c50d9a0d31506b6e9007ab7dfed5bb51ad16 /dotnet/Qpid.Client/Client/Message | |
| parent | ee94c939a9d77f0de6ae0cb33c782a9015bb8452 (diff) | |
| download | qpid-python-dbe349500e458cdf38cd4e561d27c9fa24dff7ca.tar.gz | |
Merged revisions 537954-538078,538080-538083,538085-538097,538099-538108,538110-538239,538241-538881,538883-538906,538908-538911,538913-538921,538923-539191 via svnmerge from
https://svn.apache.org/repos/asf/incubator/qpid/branches/M2
........
r537954 | tomasr | 2007-05-14 14:10:59 -0500 (Mon, 14 May 2007) | 4 lines
* QPID-487 (Contributed by Carlos Medina) Fix QpidConnectionInfo.ToString()
* QPID-485 (Contributed by Carlos Medina) Fix AmqBrokerInfo.Equals()
* QPID-456 Enforce virtual host names start with '/'
........
r538035 | tomasr | 2007-05-14 20:33:00 -0500 (Mon, 14 May 2007) | 6 lines
* QPID-452 Improve message classes API
* Add XML documentation to IChannel and IMessage
* Add missing BrokerDetailTests
* Add new tests for message creation and message factories
* Fix wrong default encoding for text messages
........
r539178 | tomasr | 2007-05-17 18:50:50 -0500 (Thu, 17 May 2007) | 6 lines
* QPID-492 Fix Race condition in message decoding
* QPID-249 Make ServiceRequestingClient and ServiceProvidingClient a single, self contained test
* Fix incorrect exception message in Qpid.Buffers, improve tests
* Make ContentBody use an sliced buffer to avoid extra data copy
* Remove useless tests in Qpid.Client (Blocking IO tests)
........
r539191 | tomasr | 2007-05-17 19:18:26 -0500 (Thu, 17 May 2007) | 1 line
QPID-490 (Contributed by Carlos Medina) Implement PurgeQueue and DeleteQueue
........
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@539198 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dotnet/Qpid.Client/Client/Message')
10 files changed, 299 insertions, 283 deletions
diff --git a/dotnet/Qpid.Client/Client/Message/AMQMessageFactory.cs b/dotnet/Qpid.Client/Client/Message/AMQMessageFactory.cs index 75c4edd67d..a7ee085a04 100644 --- a/dotnet/Qpid.Client/Client/Message/AMQMessageFactory.cs +++ b/dotnet/Qpid.Client/Client/Message/AMQMessageFactory.cs @@ -27,7 +27,7 @@ namespace Qpid.Client.Message { public abstract class AbstractQmsMessageFactory : IMessageFactory { - public abstract AbstractQmsMessage CreateMessage(); + public abstract AbstractQmsMessage CreateMessage(string mimeType); private static readonly ILog _logger = LogManager.GetLogger(typeof (AbstractQmsMessageFactory)); @@ -43,7 +43,7 @@ namespace Qpid.Client.Message if (bodies != null && bodies.Count == 1) { _logger.Debug("Non-fragmented message body (bodySize=" + contentHeader.BodySize +")"); - data = ByteBuffer.Wrap(((ContentBody)bodies[0]).Payload); + data = ((ContentBody)bodies[0]).Payload; } else { diff --git a/dotnet/Qpid.Client/Client/Message/AbstractQmsMessage.cs b/dotnet/Qpid.Client/Client/Message/AbstractQmsMessage.cs index 1d2b2db3ca..8e90e852dd 100644 --- a/dotnet/Qpid.Client/Client/Message/AbstractQmsMessage.cs +++ b/dotnet/Qpid.Client/Client/Message/AbstractQmsMessage.cs @@ -72,24 +72,29 @@ namespace Qpid.Client.Message #endregion + #region Properties + // + // Properties + // + + /// <summary> + /// The application message identifier + /// </summary> public string MessageId { - get - { + get { if (ContentHeaderProperties.MessageId == null) { ContentHeaderProperties.MessageId = "ID:" + DeliveryTag; } return ContentHeaderProperties.MessageId; } - set - { - ContentHeaderProperties.MessageId = value; - } - - - } + set { ContentHeaderProperties.MessageId = value; } + } + /// <summary> + /// The message timestamp + /// </summary> public long Timestamp { get @@ -103,36 +108,22 @@ namespace Qpid.Client.Message } } - protected void CheckReadable() - { - if (!_readableMessage) - { - throw new MessageNotReadableException("You need to call reset() to make the message readable"); - } - } - + /// <summary> + /// The <see cref="CorrelationId"/> as a byte array. + /// </summary> public byte[] CorrelationIdAsBytes { - get - { - return Encoding.Default.GetBytes(ContentHeaderProperties.CorrelationId); - } - set - { - ContentHeaderProperties.CorrelationId = Encoding.Default.GetString(value); - } + get { return Encoding.Default.GetBytes(ContentHeaderProperties.CorrelationId); } + set { ContentHeaderProperties.CorrelationId = Encoding.Default.GetString(value); } } + /// <summary> + /// The application correlation identifier + /// </summary> public string CorrelationId { - get - { - return ContentHeaderProperties.CorrelationId; - } - set - { - ContentHeaderProperties.ContentType = value; - } + get { return ContentHeaderProperties.CorrelationId; } + set { ContentHeaderProperties.CorrelationId = value; } } struct Dest @@ -147,6 +138,9 @@ namespace Qpid.Client.Message } } + /// <summary> + /// Exchange name of the reply-to address + /// </summary> public string ReplyToExchangeName { get @@ -162,6 +156,9 @@ namespace Qpid.Client.Message } } + /// <summary> + /// Routing key of the reply-to address + /// </summary> public string ReplyToRoutingKey { get @@ -177,50 +174,11 @@ namespace Qpid.Client.Message } } - /// <summary> - /// Decodes the replyto field if one is set. - /// - /// Splits a replyto field containing an exchange name followed by a ':', followed by a routing key into the exchange name and - /// routing key seperately. The exchange name may be empty in which case the empty string is returned. If the exchange name is - /// empty the replyto field is expected to being with ':'. - /// - /// Anyhting other than a two part replyto field sperated with a ':' will result in an exception. - /// </summary> - /// - /// <returns>A destination initialized to the replyto location if a replyto field was set, or an empty destination otherwise.</returns> - private Dest ReadReplyToHeader() - { - string replyToEncoding = ContentHeaderProperties.ReplyTo; - - if (replyToEncoding == null) - { - return new Dest(); - } - else - { - // Split the replyto field on a ':' - string[] split = replyToEncoding.Split(':'); - // Ensure that the replyto field argument only consisted of two parts. - if (split.Length != 2) - { - throw new QpidException("Illegal value in ReplyTo property: " + replyToEncoding); - } - - // Extract the exchange name and routing key from the split replyto field. - string exchangeName = split[0]; - string routingKey = split[1]; - - return new Dest(exchangeName, routingKey); - } - } - - private void WriteReplyToHeader(Dest dest) - { - string encodedDestination = string.Format("{0}:{1}", dest.ExchangeName, dest.RoutingKey); - ContentHeaderProperties.ReplyTo = encodedDestination; - } + /// <summary> + /// Non-persistent (1) or persistent (2) + /// </summary> public DeliveryMode DeliveryMode { get @@ -242,100 +200,94 @@ namespace Qpid.Client.Message } } + /// <summary> + /// True, if this is a redelivered message + /// </summary> public bool Redelivered { - get - { - return _redelivered; - } - set - { - _redelivered = value; - } - } + get { return _redelivered; } + set { _redelivered = value; } + } + /// <summary> + /// The message type name + /// </summary> public string Type { - get - { - return MimeType; - } - set - { - //MimeType = value; - } + get { return ContentHeaderProperties.Type; } + set { ContentHeaderProperties.Type = value; } } - + + /// <summary> + /// Message expiration specification + /// </summary> public long Expiration { - get - { - return ContentHeaderProperties.Expiration; - } - set - { - ContentHeaderProperties.Expiration = value; - } + get { return ContentHeaderProperties.Expiration; } + set { ContentHeaderProperties.Expiration = value; } } - public int Priority + /// <summary> + /// The message priority, 0 to 9 + /// </summary> + public byte Priority { - get - { - return ContentHeaderProperties.Priority; - } - set - { - ContentHeaderProperties.Priority = (byte) value; - } + get { return ContentHeaderProperties.Priority; } + set { ContentHeaderProperties.Priority = (byte) value; } } - // FIXME: implement + /// <summary> + /// The MIME Content Type + /// </summary> public string ContentType { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } + get { return ContentHeaderProperties.ContentType; } + set { ContentHeaderProperties.ContentType = value; } } - // FIXME: implement + /// <summary> + /// The MIME Content Encoding + /// </summary> public string ContentEncoding { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public void Acknowledge() - { - // the JMS 1.1 spec says in section 3.6 that calls to acknowledge are ignored when client acknowledge - // is not specified. In our case, we only set the session field where client acknowledge mode is specified. - if (_channel != null) - { - // we set multiple to true here since acknowledgement implies acknowledge of all previous messages - // received on the session - _channel.AcknowledgeMessage((ulong)DeliveryTag, true); - } - + get { return ContentHeaderProperties.Encoding; } + set { ContentHeaderProperties.Encoding = value; } } + /// <summary> + /// Headers of this message + /// </summary> public IHeaders Headers { get { return _headers; } } - public abstract void ClearBodyImpl(); + /// <summary> + /// The creating user id + /// </summary> + public string UserId + { + get { return ContentHeaderProperties.UserId; } + set { ContentHeaderProperties.UserId = value; } + } - public void ClearBody() + /// <summary> + /// The creating application id + /// </summary> + public string AppId { - ClearBodyImpl(); - _readableMessage = false; + get { return ContentHeaderProperties.AppId; } + set { ContentHeaderProperties.AppId = value; } } /// <summary> - /// Get a String representation of the body of the message. Used in the - /// toString() method which outputs this before message properties. + /// Intra-cluster routing identifier /// </summary> - /// <exception cref="QpidException"></exception> - public abstract string ToBodyString(); + public string ClusterId + { + get { return ContentHeaderProperties.ClusterId; } + set { ContentHeaderProperties.ClusterId = value; } + } /// <summary> /// Return the raw byte array that is used to populate the frame when sending @@ -367,12 +319,37 @@ namespace Qpid.Client.Message _data = value; } } + #endregion // Properties + - public abstract string MimeType + public void Acknowledge() { - get; + // the JMS 1.1 spec says in section 3.6 that calls to acknowledge are ignored when client acknowledge + // is not specified. In our case, we only set the session field where client acknowledge mode is specified. + if (_channel != null) + { + // we set multiple to true here since acknowledgement implies acknowledge of all previous messages + // received on the session + _channel.AcknowledgeMessage((ulong)DeliveryTag, true); + } + } + public abstract void ClearBodyImpl(); + + public void ClearBody() + { + ClearBodyImpl(); + _readableMessage = false; + } + + /// <summary> + /// Get a String representation of the body of the message. Used in the + /// toString() method which outputs this before message properties. + /// </summary> + /// <exception cref="QpidException"></exception> + public abstract string ToBodyString(); + public override string ToString() { try @@ -403,18 +380,6 @@ namespace Qpid.Client.Message } } - public IFieldTable UnderlyingMessagePropertiesMap - { - get - { - return ContentHeaderProperties.Headers; - } - set - { - ContentHeaderProperties.Headers = (FieldTable)value; - } - } - public FieldTable PopulateHeadersFromMessageProperties() { if (ContentHeaderProperties.Headers == null) @@ -466,5 +431,56 @@ namespace Qpid.Client.Message { get { return !_readableMessage; } } + + protected void CheckReadable() + { + if ( !_readableMessage ) + { + throw new MessageNotReadableException("You need to call reset() to make the message readable"); + } + } + + /// <summary> + /// Decodes the replyto field if one is set. + /// + /// Splits a replyto field containing an exchange name followed by a ':', followed by a routing key into the exchange name and + /// routing key seperately. The exchange name may be empty in which case the empty string is returned. If the exchange name is + /// empty the replyto field is expected to being with ':'. + /// + /// Anyhting other than a two part replyto field sperated with a ':' will result in an exception. + /// </summary> + /// + /// <returns>A destination initialized to the replyto location if a replyto field was set, or an empty destination otherwise.</returns> + private Dest ReadReplyToHeader() + { + string replyToEncoding = ContentHeaderProperties.ReplyTo; + + if ( replyToEncoding == null ) + { + return new Dest(); + } else + { + // Split the replyto field on a ':' + string[] split = replyToEncoding.Split(':'); + + // Ensure that the replyto field argument only consisted of two parts. + if ( split.Length != 2 ) + { + throw new QpidException("Illegal value in ReplyTo property: " + replyToEncoding); + } + + // Extract the exchange name and routing key from the split replyto field. + string exchangeName = split[0]; + string routingKey = split[1]; + + return new Dest(exchangeName, routingKey); + } + } + + private void WriteReplyToHeader(Dest dest) + { + string encodedDestination = string.Format("{0}:{1}", dest.ExchangeName, dest.RoutingKey); + ContentHeaderProperties.ReplyTo = encodedDestination; + } } } diff --git a/dotnet/Qpid.Client/Client/Message/IMessageFactory.cs b/dotnet/Qpid.Client/Client/Message/IMessageFactory.cs index 4a109b128e..cffc585067 100644 --- a/dotnet/Qpid.Client/Client/Message/IMessageFactory.cs +++ b/dotnet/Qpid.Client/Client/Message/IMessageFactory.cs @@ -28,11 +28,12 @@ namespace Qpid.Client.Message /// <summary> /// Create a message /// </summary> - /// <param name="messageNbr"></param> - /// <param name="redelivered"></param> - /// <param name="contentHeader"></param> - /// <param name="bodies"></param> - /// <returns></returns> + /// <param name="deliverTag">Delivery Tag</param> + /// <param name="messageNbr">Message Sequence Number</param> + /// <param name="redelivered">True if this is a redelivered message</param> + /// <param name="contentHeader">Content headers</param> + /// <param name="bodies">Message bodies</param> + /// <returns>The new message</returns> /// <exception cref="QpidMessagingException">if the message cannot be created</exception> AbstractQmsMessage CreateMessage(long deliverTag, bool redelivered, ContentHeaderBody contentHeader, @@ -41,9 +42,10 @@ namespace Qpid.Client.Message /// <summary> /// Creates the message. /// </summary> - /// <returns></returns> + /// <param name="mimeType">Mime type to associate the new message with</param> + /// <returns>The new message</returns> /// <exception cref="QpidMessagingException">if the message cannot be created</exception> - AbstractQmsMessage CreateMessage(); + AbstractQmsMessage CreateMessage(string mimeType); } } diff --git a/dotnet/Qpid.Client/Client/Message/MessageFactoryRegistry.cs b/dotnet/Qpid.Client/Client/Message/MessageFactoryRegistry.cs index 95257cef8a..f854a541fc 100644 --- a/dotnet/Qpid.Client/Client/Message/MessageFactoryRegistry.cs +++ b/dotnet/Qpid.Client/Client/Message/MessageFactoryRegistry.cs @@ -25,93 +25,104 @@ using Qpid.Messaging; namespace Qpid.Client.Message { - public class MessageFactoryRegistry - { - private readonly Hashtable _mimeToFactoryMap = new Hashtable(); + public class MessageFactoryRegistry + { + private readonly Hashtable _mimeToFactoryMap = new Hashtable(); + private IMessageFactory _defaultFactory; - public void RegisterFactory(string mimeType, IMessageFactory mf) - { - if (mf == null) - { - throw new ArgumentNullException("Message factory"); - } - if (mimeType == null) - { - throw new ArgumentNullException("mf"); - } - _mimeToFactoryMap[mimeType] = mf; - } + /// <summary> + /// Default factory to use for unknown message types + /// </summary> + public IMessageFactory DefaultFactory + { + get { return _defaultFactory; } + set { _defaultFactory = value; } + } - public void DeregisterFactory(string mimeType) - { - _mimeToFactoryMap.Remove(mimeType); - } + /// <summary> + /// Register a new message factory for a MIME type + /// </summary> + /// <param name="mimeType">Mime type to register</param> + /// <param name="mf"></param> + public void RegisterFactory(string mimeType, IMessageFactory mf) + { + if ( mf == null ) + throw new ArgumentNullException("mf"); + if ( mimeType == null || mimeType.Length == 0 ) + throw new ArgumentNullException("mimeType"); - /// <summary> - /// Create a message. This looks up the MIME type from the content header and instantiates the appropriate - /// concrete message type. - /// </summary> - /// <param name="messageNbr">the AMQ message id</param> - /// <param name="redelivered">true if redelivered</param> - /// <param name="contentHeader">the content header that was received</param> - /// <param name="bodies">a list of ContentBody instances</param> - /// <returns>the message.</returns> - /// <exception cref="AMQException"/> - /// <exception cref="QpidException"/> - public AbstractQmsMessage CreateMessage(long messageNbr, bool redelivered, - ContentHeaderBody contentHeader, - IList bodies) - { - BasicContentHeaderProperties properties = (BasicContentHeaderProperties) contentHeader.Properties; + _mimeToFactoryMap[mimeType] = mf; + } - if (properties.ContentType == null) - { - properties.ContentType = ""; - } + /// <summary> + /// Remove a message factory + /// </summary> + /// <param name="mimeType">MIME type to unregister</param> + public void DeregisterFactory(string mimeType) + { + _mimeToFactoryMap.Remove(mimeType); + } - IMessageFactory mf = (IMessageFactory) _mimeToFactoryMap[properties.ContentType]; - if (mf == null) - { - throw new AMQException("Unsupport MIME type of " + properties.ContentType); - } - else - { - return mf.CreateMessage(messageNbr, redelivered, contentHeader, bodies); - } - } + /// <summary> + /// Create a message. This looks up the MIME type from the content header and instantiates the appropriate + /// concrete message type. + /// </summary> + /// <param name="messageNbr">the AMQ message id</param> + /// <param name="redelivered">true if redelivered</param> + /// <param name="contentHeader">the content header that was received</param> + /// <param name="bodies">a list of ContentBody instances</param> + /// <returns>the message.</returns> + /// <exception cref="AMQException"/> + /// <exception cref="QpidException"/> + public AbstractQmsMessage CreateMessage(long messageNbr, bool redelivered, + ContentHeaderBody contentHeader, + IList bodies) + { + BasicContentHeaderProperties properties = (BasicContentHeaderProperties)contentHeader.Properties; - public AbstractQmsMessage CreateMessage(string mimeType) - { - if (mimeType == null) - { - throw new ArgumentNullException("Mime type must not be null"); - } - IMessageFactory mf = (IMessageFactory) _mimeToFactoryMap[mimeType]; - if (mf == null) - { - throw new AMQException("Unsupport MIME type of " + mimeType); - } - else - { - return mf.CreateMessage(); - } - } + if ( properties.ContentType == null ) + { + properties.ContentType = ""; + } - /// <summary> - /// Construct a new registry with the default message factories registered - /// </summary> - /// <returns>a message factory registry</returns> - public static MessageFactoryRegistry NewDefaultRegistry() - { - MessageFactoryRegistry mf = new MessageFactoryRegistry(); - mf.RegisterFactory("text/plain", new QpidTextMessageFactory()); - mf.RegisterFactory("text/xml", new QpidTextMessageFactory()); - mf.RegisterFactory("application/octet-stream", new QpidBytesMessageFactory()); - // TODO: use bytes message for default message factory - // MJA - just added this bit back in... - mf.RegisterFactory("", new QpidBytesMessageFactory()); - return mf; - } - } + IMessageFactory mf = GetFactory(properties.ContentType); + return mf.CreateMessage(messageNbr, redelivered, contentHeader, bodies); + } + + /// <summary> + /// Create a new message of the specified type + /// </summary> + /// <param name="mimeType">The Mime type</param> + /// <returns>The new message</returns> + public AbstractQmsMessage CreateMessage(string mimeType) + { + if ( mimeType == null || mimeType.Length == 0 ) + throw new ArgumentNullException("mimeType"); + + IMessageFactory mf = GetFactory(mimeType); + return mf.CreateMessage(mimeType); + } + + /// <summary> + /// Construct a new registry with the default message factories registered + /// </summary> + /// <returns>a message factory registry</returns> + public static MessageFactoryRegistry NewDefaultRegistry() + { + MessageFactoryRegistry mf = new MessageFactoryRegistry(); + mf.RegisterFactory("text/plain", new QpidTextMessageFactory()); + mf.RegisterFactory("text/xml", new QpidTextMessageFactory()); + mf.RegisterFactory("application/octet-stream", new QpidBytesMessageFactory()); + + mf.DefaultFactory = new QpidBytesMessageFactory(); + return mf; + } + + private IMessageFactory GetFactory(string mimeType) + { + IMessageFactory mf = (IMessageFactory)_mimeToFactoryMap[mimeType]; + return mf != null ? mf : _defaultFactory; + } + } } diff --git a/dotnet/Qpid.Client/Client/Message/QpidBytesMessage.cs b/dotnet/Qpid.Client/Client/Message/QpidBytesMessage.cs index 32e47d852a..cb504d1378 100644 --- a/dotnet/Qpid.Client/Client/Message/QpidBytesMessage.cs +++ b/dotnet/Qpid.Client/Client/Message/QpidBytesMessage.cs @@ -43,8 +43,6 @@ namespace Qpid.Client.Message public class QpidBytesMessage : AbstractQmsMessage, IBytesMessage { - private const string MIME_TYPE = "application/octet-stream"; - private const int DEFAULT_BUFFER_INITIAL_SIZE = 1024; public QpidBytesMessage() : this(null) @@ -59,7 +57,6 @@ namespace Qpid.Client.Message QpidBytesMessage(ByteBuffer data) : base(data) { // superclass constructor has instantiated a content header at this point - ContentHeaderProperties.ContentType = MIME_TYPE; if (data == null) { _data = ByteBuffer.Allocate(DEFAULT_BUFFER_INITIAL_SIZE); @@ -71,7 +68,6 @@ namespace Qpid.Client.Message // TODO: this casting is ugly. Need to review whole ContentHeaderBody idea : base(messageNbr, (BasicContentHeaderProperties)contentHeader.Properties, data) { - ContentHeaderProperties.ContentType = MIME_TYPE; } public override void ClearBodyImpl() @@ -116,14 +112,6 @@ namespace Qpid.Client.Message } } - public override string MimeType - { - get - { - return MIME_TYPE; - } - } - public long BodyLength { get diff --git a/dotnet/Qpid.Client/Client/Message/QpidBytesMessageFactory.cs b/dotnet/Qpid.Client/Client/Message/QpidBytesMessageFactory.cs index de4c6675c7..e96c38cbac 100644 --- a/dotnet/Qpid.Client/Client/Message/QpidBytesMessageFactory.cs +++ b/dotnet/Qpid.Client/Client/Message/QpidBytesMessageFactory.cs @@ -62,9 +62,11 @@ namespace Qpid.Client.Message return new QpidBytesMessage(deliveryTag, contentHeader, data); } - public override AbstractQmsMessage CreateMessage() + public override AbstractQmsMessage CreateMessage(string mimeType) { - return new QpidBytesMessage(); + QpidBytesMessage msg = new QpidBytesMessage(); + msg.ContentType = mimeType; + return msg; } } diff --git a/dotnet/Qpid.Client/Client/Message/QpidHeaders.cs b/dotnet/Qpid.Client/Client/Message/QpidHeaders.cs index 6538fcbefc..a258c82d15 100644 --- a/dotnet/Qpid.Client/Client/Message/QpidHeaders.cs +++ b/dotnet/Qpid.Client/Client/Message/QpidHeaders.cs @@ -28,16 +28,10 @@ namespace Qpid.Client.Message _headers.Clear(); } - public string this[string name] + public object this[string name] { - get - { - return GetString(name); - } - set - { - SetString(name, value); - } + get { return GetObject(name); } + set { SetObject(name, value); } } public bool GetBoolean(string name) @@ -167,6 +161,18 @@ namespace Qpid.Client.Message _headers.SetString(propertyName, value); } + public object GetObject(string propertyName) + { + CheckPropertyName(propertyName); + return _headers[propertyName]; + } + + public void SetObject(string propertyName, object value) + { + CheckPropertyName(propertyName); + _headers[propertyName] = value; + } + private static void CheckPropertyName(string propertyName) { if ( propertyName == null ) diff --git a/dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs b/dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs index cff42f1df5..ae8bdb2074 100644 --- a/dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs +++ b/dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs @@ -28,25 +28,22 @@ namespace Qpid.Client.Message { public class QpidTextMessage : AbstractQmsMessage, ITextMessage { - private const string MIME_TYPE = "text/plain"; - private string _decodedValue = null; + private static Encoding DEFAULT_ENCODING = Encoding.UTF8; internal QpidTextMessage() : this(null, null) { + ContentEncoding = DEFAULT_ENCODING.BodyName; } - QpidTextMessage(ByteBuffer data, String encoding) : base(data) + internal QpidTextMessage(ByteBuffer data, String encoding) : base(data) { - ContentHeaderProperties.ContentType = MIME_TYPE; - ContentHeaderProperties.Encoding = encoding; + ContentEncoding = encoding; } internal QpidTextMessage(long deliveryTag, BasicContentHeaderProperties contentHeader, ByteBuffer data) :base(deliveryTag, contentHeader, data) { - contentHeader.ContentType = MIME_TYPE; - _data = data; // FIXME: Unnecessary - done in base class ctor. } public override void ClearBodyImpl() @@ -64,14 +61,6 @@ namespace Qpid.Client.Message return Text; } - public override string MimeType - { - get - { - return MIME_TYPE; - } - } - public string Text { get @@ -100,7 +89,7 @@ namespace Qpid.Client.Message } else { - _decodedValue = Encoding.Default.GetString(bytes); + _decodedValue = DEFAULT_ENCODING.GetString(bytes); } return _decodedValue; } diff --git a/dotnet/Qpid.Client/Client/Message/QpidTextMessageFactory.cs b/dotnet/Qpid.Client/Client/Message/QpidTextMessageFactory.cs index cc4f6dafe1..4730fa56ad 100644 --- a/dotnet/Qpid.Client/Client/Message/QpidTextMessageFactory.cs +++ b/dotnet/Qpid.Client/Client/Message/QpidTextMessageFactory.cs @@ -25,9 +25,11 @@ namespace Qpid.Client.Message { public class QpidTextMessageFactory : AbstractQmsMessageFactory { - public override AbstractQmsMessage CreateMessage() + public override AbstractQmsMessage CreateMessage(string mimeType) { - return new QpidTextMessage(); + QpidTextMessage msg = new QpidTextMessage(); + msg.ContentType = mimeType; + return msg; } protected override AbstractQmsMessage CreateMessage(long deliveryTag, ByteBuffer data, ContentHeaderBody contentHeader) diff --git a/dotnet/Qpid.Client/Client/Message/UnprocessedMessage.cs b/dotnet/Qpid.Client/Client/Message/UnprocessedMessage.cs index cb4e64718b..b64c8e1c27 100644 --- a/dotnet/Qpid.Client/Client/Message/UnprocessedMessage.cs +++ b/dotnet/Qpid.Client/Client/Message/UnprocessedMessage.cs @@ -43,7 +43,7 @@ namespace Qpid.Client.Message Bodies.Add(body); if (body.Payload != null) { - _bytesReceived += (uint)body.Payload.Length; + _bytesReceived += (uint)body.Payload.Remaining; } } |
