Dışarıya aktar (0) Yazdır
Tümünü Genişlet
EN
Bu içerik dilinizde bulunmamaktadır ancak İngilizce sürümüne buradan bakabilirsiniz.
2 / 2 bunu faydalı olarak değerlendirdi - Bu konuyu değerlendir

How to: Create and Connect to a Service Bus Message Buffer

After you have specified the desired configuration of your message buffer by creating a message buffer policy (see How to: Configure a Service Bus Message Buffer), you must define the Windows Azure Service Bus endpoint URI for the message buffer, and then instruct the Service Bus to instantiate and expose a message buffer at that location.

The following table lists the operations available to create, access, and delete a message buffer using the REST protocol.

 

Resource URI

HTTP Verb

Description

https://{serviceNamespace}.servicebus.windows.net/{path}/{buffer}

PUT

Creates a message buffer on the Service Bus with the specified policy.

GET

Retrieves the message buffer policy.

DELETE

Deletes the message buffer along with its policy and all associated state.

The following table lists the methods available to create, access, and delete a message buffer using the Windows Azure SDK.

 

Method

Description

CreateMessageBuffer

Creates a message buffer on the Service Bus with the specified policy and location.

GetMessageBuffer

Connects to a pre-existing message buffer.

DeleteMessageBuffer

Deletes the message buffer.

noteNote
You can create only one message buffer at a given Service Bus endpoint. Furthermore, when a message buffer is open on a given endpoint, no other services can be open on that same endpoint.

To create and delete a Service Bus message buffer using the REST protocol

  1. Send a PUT HTTP request to create a message buffer using the authorization header and message buffer policy previously created in How to: Configure a Service Bus Message Buffer.

    WebClient client = new WebClient();
    client.BaseAddress = string.Format("https://{0}.servicebus.windows.net/{1}/", serviceNamespace, bufferName);
    client.Headers[HttpRequestHeader.ContentType] = "application/atom+xml;type=entry;charset=utf-8";
    client.Headers[HttpRequestHeader.Authorization] = authHeaderValue;
    client.UploadData(String.Empty, "PUT", Encoding.UTF8.GetBytes(policy));
    
    
  2. At this point, you can send and receive messages from the message buffer. For more information, see How to: Send Messages to a Service Bus Message Buffer and How to: Retrieve a Message from a Service Bus Message Buffer.

  3. To maintain the existence of the message buffer, periodically request a message from the buffer.

    A message buffer renews its own lifespan implicitly whenever a request for a message is received. This is the only method currently supported for renewing the lifespan of a message buffer.

  4. When finished, you can delete the message buffer by sending the following DELETE HTTP request.

    client.Headers[HttpRequestHeader.Authorization] = authHeaderValue;
    client.UploadData(String.Empty, "DELETE", new byte[0]);  
    
    

    You do not have to delete the message buffer when you are finished: all message buffers have an expiration time that causes the Service Bus to automatically delete the buffer. However, you may want to delete the buffer before this expiration time. For more information, see the ExpiresAfter property.

To create and delete a Service Bus message buffer using the Windows Azure SDK

  1. Create a URI that contains the address of the buffer.

    Uri bufferLocation = new Uri("https://" + serviceNamespace + ".servicebus.windows.net/services/MyBuffer");
    
  2. Create the buffer by calling the CreateMessageBuffer method.

    MessageBufferClient client = MessageBufferClient.CreateMessageBuffer(behavior, bufferLocation, policy);
    

    You can also obtain access to a pre-existing message buffer by calling the GetMessageBuffer method.

  3. At this point, you can send and receive messages from the message buffer. For more information, see How to: Send Messages to a Service Bus Message Buffer and How to: Retrieve a Message from a Service Bus Message Buffer.

  4. To maintain the existence of the message buffer, periodically request a message from the buffer.

    A message buffer renews its own lifespan implicitly whenever a request for a message is received. This is the only method currently supported for renewing the lifespan of a message buffer.

  5. When finished, you can close the message buffer by calling the DeleteMessageBuffer method.

    You do not have to delete the message buffer when you are finished: all buffers have an expiration time that causes the Service Bus to automatically delete the buffer. However, you may want to delete the buffer before this expiration time. For more information, see the ExpiresAfter property.

Bunu faydalı buldunuz mu?
(1500 karakter kaldı)
Geri bildiriminiz için teşekkür ederiz

Topluluk İçeriği

Show:
© 2014 Microsoft. Tüm hakları saklıdır.