Share via


GetPolicy Method

Retrieves the policy of the message buffer with which the current instance is associated.

Namespace:  Microsoft.ServiceBus
Assembly:  Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)

Syntax

'Declaration
Public Function GetPolicy As MessageBufferPolicy
'Usage
Dim instance As MessageBufferClient
Dim returnValue As MessageBufferPolicy

returnValue = instance.GetPolicy()
public MessageBufferPolicy GetPolicy()
public:
MessageBufferPolicy^ GetPolicy()
member GetPolicy : unit -> MessageBufferPolicy 
public function GetPolicy() : MessageBufferPolicy

Return Value

Type: Microsoft.ServiceBus. . :: . .MessageBufferPolicy
Returns a MessageBufferPolicy that contains the message buffer policy.

Remarks

The message buffer policy sets the life span, maximum message count, and overflow policy for the message buffer. For more information, see How to: Configure an AppFabric Service Bus Message Buffer.

Examples

The following code example shows how to set the policy on a 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 = "REPLACE WITH ISSUER NAME";
behavior.Credentials.SharedSecret.IssuerSecret = "REPLACE WITH ISSUER SECRET";

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

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

See Also

Reference

MessageBufferClient Class

Microsoft.ServiceBus Namespace