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.
1 / 2 bunu faydalı olarak değerlendirdi - Bu konuyu değerlendir

MessageSender Class

The MessageSender class is used to send messages from the Service Bus. Although you can use the QueueClient class to send and receive messages without creating a MessageSender object, you can also use MessageSender and MessageReceiver to create a sender and receiver on an entity without knowing whether it is a topic or a queue.

Namespace:  Microsoft.ServiceBus.Messaging
Assembly:  Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)
public ref class MessageSender abstract : public MessageClientEntity

The MessageSender type exposes the following members.

  NameDescription
Public propertyBatchFlushIntervalGets the batch flush interval.
Protected propertyBatchingEnabledGets a value indicating whether the batching is enabled.
Public propertyIsClosedGets or sets a value that indicates whether the message client entity is closed. (Inherited from MessageClientEntity.)
Public propertyPathGets the path of the queue or topic relative to the MessagingFactory base address.
Public propertyRetryPolicyGets or sets a retry policy associated with this instance that determines whether if the request should be retried. (Inherited from MessageClientEntity.)
Protected propertyThisLockGents an object used for locking the MessageClientEntity instance. (Inherited from MessageClientEntity.)
Top
  NameDescription
Public methodAbortAborts the message client entity and puts its status into a closing state. (Inherited from MessageClientEntity.)
Public methodBeginCloseBegins an asynchronous operation to close the message client entity. (Inherited from MessageClientEntity.)
Public methodBeginSendBegins an asynchronous request to send a brokered message.
Public methodBeginSendBatchBegins an asynchronous request to send a brokered message by batch.
Public methodCloseCloses the message client entity and puts its status into a closed state. (Inherited from MessageClientEntity.)
Public methodCloseAsyncAsynchronously closes the message client entity and puts its status into a closed state. (Inherited from MessageClientEntity.)
Public methodEndCloseFinishes an asynchronous operation to close the message client entity. (Inherited from MessageClientEntity.)
Public methodEndSendEnds an asynchronous request to send a message.
Public methodEndSendBatchEnds an asynchronous request to send a message by batch.
Public methodEquals (Inherited from Object.)
Protected methodFaultPuts the message client entity into a faulted state. (Inherited from MessageClientEntity.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Protected methodOnAbortExecutes upon calling the Abort operation. (Inherited from MessageClientEntity.)
Protected methodOnBeginCloseExecutes upon calling the BeginClose operation. (Inherited from MessageClientEntity.)
Protected methodOnBeginOpenExecutes upon calling the operation to begin to open the message client entity. (Inherited from MessageClientEntity.)
Protected methodOnBeginSendAllows concrete implementations to define what should be done when sending messages. This method cannot be implemented in a concrete class by the user.
Protected methodOnCloseExecutes upon calling the Close operation. (Inherited from MessageClientEntity.)
Protected methodOnClosedOccurs when the message client entity is transitioned into a closing state. (Inherited from MessageClientEntity.)
Protected methodOnEndCloseExecutes upon calling the EndClose operation. (Inherited from MessageClientEntity.)
Protected methodOnEndOpenExecutes upon calling the operation to end to open the message client entity. (Inherited from MessageClientEntity.)
Protected methodOnEndSendExecutes the end send action. This method cannot be implemented in a concrete class by the user.
Protected methodOnFaultedExecutes upon calling the Fault operation. (Inherited from MessageClientEntity.)
Protected methodOnOpenExecutes upon calling the operation to open the message client entity. (Inherited from MessageClientEntity.)
Protected methodOnOpenedExecutes when the message client entity is opened. (Inherited from MessageClientEntity.)
Protected methodOnSendAllows concrete implementations to override (if needed) what should be done when sending messages in a synchronous manner.
Public methodSendSends the specified brokered message.
Public methodSendAsyncAsynchronously sends the specified brokered message.
Public methodSendBatchSends a set of brokered messages (for batch processing).
Public methodSendBatchAsyncAsynchronously sends a set of brokered messages (for batch processing).
Protected methodThrowIfClosedThrows an exception if the message client entity is closed. (Inherited from MessageClientEntity.)
Protected methodThrowIfDisposedThrows an exception if the message client entity is disposed. (Inherited from MessageClientEntity.)
Protected methodThrowIfDisposedOrImmutableThrows an exception if the client is disposed or immutable. (Inherited from MessageClientEntity.)
Protected methodThrowIfDisposedOrNotOpenThrows an exception if the client is disposed or not open. (Inherited from MessageClientEntity.)
Protected methodThrowIfFaultedThrows an exception if the client is faulted. (Inherited from MessageClientEntity.)
Public methodToString (Inherited from Object.)
Top

Note that the default message receive mode is PeekLock, which ensures reliable message receiving.

The following example sends messages to a queue.

Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", ServiceNamespace, string.Empty); 

MessagingFactory factory = MessagingFactory.Create(serviceUri, credentials); 

MessageSender myMessageSender = factory.CreateMessageSender(queueName); 

List<BrokeredMessage> messageList = new List<BrokeredMessage>();
messageList.Add(CreateIssueMessage("1", "Package lost"));
messageList.Add(CreateIssueMessage("2", "Package damaged"));
messageList.Add(CreateIssueMessage("3", "Package defective"));

foreach (BrokeredMessage message in messageList)
{
    myMessageSender.Send(message);
    Console.WriteLine(
    string.Format("Message sent: Id = {0}, Body = {1}", message.MessageId, message.GetBody<string>()));
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Instance members are also guaranteed to be thread safe.

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

Topluluk İçeriği

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