MSDN Library
EN
Bu içerik dilinizde bulunmamaktadır ancak İngilizce sürümüne buradan bakabilirsiniz.

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)

System.Object
  Microsoft.ServiceBus.Messaging.ClientEntity
    Microsoft.ServiceBus.Messaging.MessageSender

[<AbstractClass>]
type MessageSender = 
    class
        inherit ClientEntity
    end

NameDescription
System_CAPS_pubpropertyBatchFlushInterval

Gets the batch flush interval.

System_CAPS_protpropertyBatchingEnabled

Gets a value indicating whether the batching is enabled.

System_CAPS_pubpropertyIsClosed

(Inherited from ClientEntity.)

System_CAPS_pubpropertyPath

Gets the path of the queue or topic relative to the MessagingFactory base address.

System_CAPS_pubpropertyRetryPolicy

(Inherited from ClientEntity.)

System_CAPS_protpropertySupportsGetRuntimeEntityDescription

System_CAPS_protpropertyThisLock

(Inherited from ClientEntity.)

NameDescription
System_CAPS_pubmethodAbort()

Performs abort functionality on the messaging entity.(Inherited from ClientEntity.)

System_CAPS_pubmethodClose()

Sends a cleanup message to Service Bus to signal the completion of the usage of an entity.(Inherited from ClientEntity.)

System_CAPS_pubmethodCloseAsync()

Sends a cleanup message asynchronously to Service Bus to signal the completion of the usage of an entity.(Inherited from ClientEntity.)

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFault()

For internal use only. Do not inherit from this class.(Inherited from ClientEntity.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_protmethodOnAbort()

(Inherited from ClientEntity.)

System_CAPS_protmethodOnBeginCancelScheduledMessage(TrackingContext, IEnumerable<Int64>, TimeSpan, AsyncCallback, Object)

Raises an event that starts the cancellation of the scheduled message.

System_CAPS_protmethodOnBeginClose(TimeSpan, AsyncCallback, Object)

(Inherited from ClientEntity.)

System_CAPS_protmethodOnBeginOpen(TimeSpan, AsyncCallback, Object)

(Inherited from ClientEntity.)

System_CAPS_protmethodOnBeginScheduleMessage(TrackingContext, IEnumerable<BrokeredMessage>, TimeSpan, AsyncCallback, Object)

Raises an event when scheduling a message.

System_CAPS_protmethodOnBeginSend(TrackingContext, IEnumerable<BrokeredMessage>, Boolean, TimeSpan, AsyncCallback, Object)

Allows concrete implementations to define what should be done when sending messages. This method cannot be implemented in a concrete class by the user.

System_CAPS_protmethodOnBeginSendEventData(TrackingContext, IEnumerable<EventData>, TimeSpan, AsyncCallback, Object)

Raises an event when sending event data.

System_CAPS_protmethodOnClose(TimeSpan)

(Inherited from ClientEntity.)

System_CAPS_protmethodOnClosed()

(Inherited from ClientEntity.)

System_CAPS_protmethodOnEndCancelScheduledMessage(IAsyncResult)

Raises an event when ending the cancellation of the scheduled message.

System_CAPS_protmethodOnEndClose(IAsyncResult)

(Inherited from ClientEntity.)

System_CAPS_protmethodOnEndOpen(IAsyncResult)

(Inherited from ClientEntity.)

System_CAPS_protmethodOnEndScheduleMessage(IAsyncResult)

Raises an event when ending the message schedule.

System_CAPS_protmethodOnEndSend(IAsyncResult)

Executes the end send action. This method cannot be implemented in a concrete class by the user.

System_CAPS_protmethodOnEndSendEventData(IAsyncResult)

Executes the end send event data action.

System_CAPS_protmethodOnFaulted()

(Inherited from ClientEntity.)

System_CAPS_protmethodOnOpen(TimeSpan)

(Inherited from ClientEntity.)

System_CAPS_protmethodOnOpened()

(Inherited from ClientEntity.)

System_CAPS_protmethodOnSend(TrackingContext, IEnumerable<BrokeredMessage>, TimeSpan)

Allows concrete implementations to override (if needed) what should be done when sending messages in a synchronous manner.

System_CAPS_pubmethodSend(BrokeredMessage)

Sends the specified brokered message.

System_CAPS_pubmethodSendAsync(BrokeredMessage)

Asynchronously sends the specified brokered message.

System_CAPS_pubmethodSendBatch(IEnumerable<BrokeredMessage>)

Sends a set of brokered messages (for batch processing).

System_CAPS_pubmethodSendBatchAsync(IEnumerable<BrokeredMessage>)

Asynchronously sends a set of brokered messages (for batch processing).

System_CAPS_protmethodThrowIfClosed()

(Inherited from ClientEntity.)

System_CAPS_protmethodThrowIfDisposed()

(Inherited from ClientEntity.)

System_CAPS_protmethodThrowIfDisposedOrImmutable()

(Inherited from ClientEntity.)

System_CAPS_protmethodThrowIfDisposedOrNotOpen()

(Inherited from ClientEntity.)

System_CAPS_protmethodThrowIfFaulted()

(Inherited from ClientEntity.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

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.

Return to top
Show:
© 2016 Microsoft