Message​Sender Class

Definition

The MessageSender class is used to send messages from the Service Bus.

public abstract class MessageSender : Microsoft.ServiceBus.Messaging.ClientEntity
Inheritance
MessageSender

Inherited Members

Microsoft.ServiceBus.Messaging.ClientEntity

Remarks

Please note that message delivery mechanism does not provide by default all time reliable message receiving. Service Bus deletes the message once it goes out of the system. For a guaranteed delivery, you can use the PeekLock delivery mode.


             //********************************************************************************
             //                             Sending messages to a Queue
             //********************************************************************************

         // Create a sender
         MessageSender myMessageSender = myQueueClient.CreateSender(SendMode.Default);

         // Send messages
         List<object> Issues = new List<object>();
         foreach (var issue in Issues)
         {
         myMessageSender.Send(new BrokeredMessage(issue));
         }
         </code></pre></example><example><pre><code>
         //********************************************************************************
         //                           Recieving messages from a Queue
         //********************************************************************************

         // Create a receiver
         MessageReceiver myMessageReceiver = 
         myQueueClient.CreateReceiver(ReceiveMode.PeekLock);

         // Receive messages
         for (int count = 0; count < Issues.Count; count++)
         {
         var message = myMessageReceiver.Receive();
         message.Complete();
         }
         </code></pre></example>

Properties

Batch​Flush​Interval

Gets the batch flush interval.

Batching​Enabled

Gets a value indicating whether the batching is enabled.

Path

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

Supports​Get​Runtime​Entity​Description

Methods

On​Begin​Cancel​Scheduled​Message(​Tracking​Context, ​IEnumerable<​Int64>, ​Time​Span, ​Async​Callback, ​Object)

This allows concrete implementations to override (if needed) what should be done to cancel scheduled sends

On​Begin​Schedule​Message(​Tracking​Context, ​IEnumerable<​Brokered​Message>, ​Time​Span, ​Async​Callback, ​Object)

This allows concrete implementations to override (if needed) what should be done to schedule sends

On​Begin​Send(​Tracking​Context, ​IEnumerable<​Brokered​Message>, ​Boolean, ​Time​Span, ​Async​Callback, ​Object)

Executes the begin send action. This method is intended for internal consumption and cannot be implemented in a concrete class by the user.

On​Begin​Send​Event​Data(​Tracking​Context, ​IEnumerable<​Event​Data>, ​Time​Span, ​Async​Callback, ​Object)

Executes the begin send event data action. This method is intended for internal consumption and cannot be implemented in a concrete class by the user.

On​End​Cancel​Scheduled​Message(​IAsync​Result)

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

On​End​Schedule​Message(​IAsync​Result)

Raises an event when ending the message schedule.

On​End​Send(​IAsync​Result)

Executes the end send action. This method is intended for internal consumption and cannot be implemented in a concrete class by the user.

On​End​Send​Event​Data(​IAsync​Result)

Executes the end send event data action. This method is intended for internal consumption and cannot be implemented in a concrete class by the user.

On​Send(​Tracking​Context, ​IEnumerable<​Brokered​Message>, ​Time​Span)

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

Send(​Brokered​Message)

Sends the specified brokered message.

Send​Async(​Brokered​Message)

Asynchronously sends the specified brokered message.

Send​Batch(​IEnumerable<​Brokered​Message>)

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

Send​Batch​Async(​IEnumerable<​Brokered​Message>)

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