This topic has not yet been rated - Rate this topic

MessageBufferPolicy Class

The policy to set on an Service Bus message buffer endpoint.

System.Object
  Microsoft.ServiceBus.MessageBufferPolicy

Namespace:  Microsoft.ServiceBus
Assembly:  Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)
[DataContractAttribute(Name = "MessageBufferPolicy", Namespace = "http://schemas.microsoft.com/netservices/2009/05/servicebus/connect")]
public class MessageBufferPolicy : IExtensibleDataObject

The MessageBufferPolicy type exposes the following members.

  Name Description
Public method MessageBufferPolicy() Initializes a new instance of the MessageBufferPolicy class.
Public method MessageBufferPolicy(MessageBufferPolicy) Initializes a new instance of the MessageBufferPolicy class, using the specified message buffer as a copy.
Top
  Name Description
Public property Authorization Gets or sets the authorization policy for the message buffer.
Public property Discoverability Gets or sets the discoverability policy for the message buffer.
Public property ExpiresAfter Gets or sets the duration after which the message buffer expires.
Public property MaxMessageCount Gets or sets the maximum message count.
Public property OverflowPolicy Gets or sets the overflow policy.
Public property TransportProtection Gets or sets the transport protection policy.
Top
  Name Description
Public method Equals Returns a value that indicates whether the specified object has the same properties as this message buffer policy. (Overrides Object.Equals(Object).)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Overrides Object.GetHashCode().)
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method ToString (Inherited from Object.)
Top
  Name Description
Explicit interface implemetation Private property IExtensibleDataObject.ExtensionData Gets or sets the structure that contains extra data.
Top

The message buffer policy controls the type of security used on the message buffer, as well as the lifespan of the message buffer, and what to do when the buffer fills up with messages. For more information on setting message buffer policy, see How to: Configure an AppFabric Service Bus Message Buffer.

The following code example describes how to create a message buffer policy and use it to instantiate a new message buffer.

string serviceNamespace = "myServiceNamespace";

MessageVersion messageVersion = MessageVersion.Soap12WSAddressing10;
string messageAction = "urn:Message";

// Configure credentials
TransportClientEndpointBehavior behavior = new TransportClientEndpointBehavior();
behavior.CredentialType = TransportClientCredentialType.SharedSecret;
behavior.Credentials.SharedSecret.IssuerName = "...";
behavior.Credentials.SharedSecret.IssuerSecret = "...";

// Configure buffer policy
MessageBufferPolicy policy = new MessageBufferPolicy
{
    ExpiresAfter = TimeSpan.FromMinutes(2.0d),
    MaxMessageCount = 100
};

// Create buffer
Uri bufferName = new Uri("https://" + serviceNamespace + ".servicebus.windows.net/services/MyBuffer");
MessageBufferClient client = MessageBufferClient.CreateMessageBuffer(behavior, bufferName, policy, messageVersion);

// Send some messages
for (int i = 0; i < 10; ++i)
{
    client.Send(Message.CreateMessage(messageVersion, messageAction, "Message #" + i);
}

Message message;
string content;

// Retrieve a message (destructive read)
message = client.Retrieve();
content = message.GetBody<string>();
message.Close();

Console.WriteLine("Retrieve message content: {0}", content);

// Retrieve a message (peek/lock)
message = client.PeekLock();
content = message.GetBody<string>();

Console.WriteLine("PeekLock message content: {0}", content);

// Delete previously locked message
client.DeleteLockedMessage(message);
message.Close();

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)