Méthode CreateMessageBuffer (TransportClientEndpointBehavior, Uri, MessageBufferPolicy, MessageVersion)

Crée un tampon des messages sur le bus des services Windows Azure, en utilisant les informations d'identification, l'URI, la stratégie et la version de message spécifiés.

Espace de noms :  Microsoft.ServiceBus
Assembly :  Microsoft.ServiceBus (en Microsoft.ServiceBus.dll)

public static MessageBufferClient CreateMessageBuffer(
	TransportClientEndpointBehavior credential,
	Uri messageBufferUri,
	MessageBufferPolicy messageBufferPolicy,
	MessageVersion messageVersion
)

Paramètres

credential
Type : Microsoft.ServiceBus..::..TransportClientEndpointBehavior
Informations d'identification à utiliser pour accéder au tampon des messages.
messageBufferUri
Type : System..::..Uri
URI pour le tampon des messages.
messageBufferPolicy
Type : Microsoft.ServiceBus..::..MessageBufferPolicy
Stratégie à appliquer au tampon des messages.
messageVersion
Type : System.ServiceModel.Channels..::..MessageVersion
Version des messages dont l'envoi au tampon des messages est autorisé.

Valeur de retour

Type : Microsoft.ServiceBus..::..MessageBufferClient
Retourne un code MessageBufferClient contenant le client du tampon des messages qui interagira avec le tampon des messages.

Use this constructor if you want to specify the type of message your message buffer will retrieve. By default, a message buffer will take any type of valid message sent to it, and will not filter. Therefore, you can use this constructor to restrict other clients from sending any type of message but the one you specify.

RemarqueRemarque

Creating a message buffer with a name that already exists does not throw an error.

The message buffer URI should be in the following format:

http://{serviceNamespace}.servicebus.windows.net/{path}/{buffername}
http://{serviceNamespace}.servicebus.windows.net/{path}/{buffername}

For more information in creating a message buffer, see How to: Create an AppFabric Service Bus Message Buffer and the Message Buffer Overview.

The following code example shows how to instantiate a message buffer using this constructor.

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 = 100
};

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

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 = 100
};

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

Afficher: