Udostępnij za pośrednictwem


MessageSender Class

Definition

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

public abstract class MessageSender : Microsoft.ServiceBus.Messaging.MessagingEntityClient
type MessageSender = class
    inherit MessagingEntityClient
Public MustInherit Class MessageSender
Inherits MessagingEntityClient
Inheritance

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));
}
//********************************************************************************
//                           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();
}

Properties

BatchFlushInterval

Gets the batch flush interval.

BatchingEnabled

Gets a value indicating whether the batching is enabled.

IsClosed (Inherited from ClientEntity)
Path

Gets the queue's, topic's, or subscription's path relative to the MessagingFactory base address.

(Inherited from MessagingEntityClient)
RefreshEntityRuntimeDescription
RetryPolicy (Inherited from ClientEntity)
SupportsGetRuntimeEntityDescription
ThisLock (Inherited from ClientEntity)

Methods

Abort()

Performs abort functionality on the messaging entity.

(Inherited from ClientEntity)
Close()

Sends a cleanup message to Service Bus to signal the completion of the usage of an entity.

(Inherited from ClientEntity)
CloseAsync()

Sends a cleanup message asynchronously to Service Bus to signal the completion of the usage of an entity.

(Inherited from ClientEntity)
Fault()

For internal use only. Do not inherit from this class.

(Inherited from ClientEntity)
OnAbort() (Inherited from ClientEntity)
OnBeginCancelScheduledMessage(TrackingContext, IEnumerable<Int64>, TimeSpan, AsyncCallback, Object)

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

OnBeginClose(TimeSpan, AsyncCallback, Object) (Inherited from ClientEntity)
OnBeginOpen(TimeSpan, AsyncCallback, Object) (Inherited from ClientEntity)
OnBeginScheduleMessage(TrackingContext, IEnumerable<BrokeredMessage>, TimeSpan, AsyncCallback, Object)

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

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

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

OnBeginSendEventData(TrackingContext, IEnumerable<EventData>, TimeSpan, AsyncCallback, 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.

OnClose(TimeSpan) (Inherited from ClientEntity)
OnClosed() (Inherited from ClientEntity)
OnEndCancelScheduledMessage(IAsyncResult)

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

OnEndClose(IAsyncResult) (Inherited from ClientEntity)
OnEndOpen(IAsyncResult) (Inherited from ClientEntity)
OnEndScheduleMessage(IAsyncResult)

Raises an event when ending the message schedule.

OnEndSend(IAsyncResult)

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

OnEndSendEventData(IAsyncResult)

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.

OnFaulted() (Inherited from ClientEntity)
OnOpen(TimeSpan) (Inherited from ClientEntity)
OnOpened() (Inherited from ClientEntity)
OnSend(TrackingContext, IEnumerable<BrokeredMessage>, TimeSpan)

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

Send(BrokeredMessage)

Sends the specified brokered message.

SendAsync(BrokeredMessage)

Asynchronously sends the specified brokered message.

SendBatch(IEnumerable<BrokeredMessage>)

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

SendBatchAsync(IEnumerable<BrokeredMessage>)

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

ThrowIfClosed() (Inherited from ClientEntity)
ThrowIfDisposed() (Inherited from ClientEntity)
ThrowIfDisposedOrImmutable() (Inherited from ClientEntity)
ThrowIfDisposedOrNotOpen() (Inherited from ClientEntity)
ThrowIfFaulted() (Inherited from ClientEntity)

Applies to