Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

MessageBufferPolicy Class

The policy to set on an Windows Azure 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.

  NameDescription
Public methodMessageBufferPolicy()()()()Initializes a new instance of the MessageBufferPolicy class.
Public methodMessageBufferPolicy(MessageBufferPolicy)Initializes a new instance of the MessageBufferPolicy class, using the specified message buffer as a copy.
Top

  NameDescription
Public propertyAuthorizationGets or sets the authorization policy for the message buffer.
Public propertyDiscoverabilityGets or sets the discoverability policy for the message buffer.
Public propertyExpiresAfterGets or sets the duration after which the message buffer expires.
Public propertyMaxMessageCountGets or sets the maximum message count.
Public propertyOverflowPolicyGets or sets the overflow policy.
Public propertyTransportProtectionGets or sets the transport protection policy.
Top

  NameDescription
Public methodEqualsReturns a value that indicates whether the specified object has the same properties as this message buffer policy. (Overrides Object..::..Equals(Object).)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Overrides Object..::..GetHashCode()()()().)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Top

Important noteImportant

The current Message Buffers feature, including their management protocol, will remain supported for backwards compatibility. However, the general recommendation is that you explicitly change client code to use the new Queue feature. For more information, see Service Bus Queues, Topics, and Subscriptions.

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.

Community Additions

Show:
© 2015 Microsoft