Class MessageSender
- Namespace
- Microsoft.ServiceBus.Messaging
- Assembly
- Microsoft.ServiceBus.dll
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.
public abstract class MessageSender : ClientEntity
- Inheritance
-
MessageSender
- Inherited Members
Properties
BatchFlushInterval
Gets the batch flush interval.
public virtual TimeSpan BatchFlushInterval { get; }
Property Value
- TimeSpan
A batch flush interval. The default value is 20 ms.
Exceptions
- OperationCanceledException
Thrown when the MessageSender is in closing, closed, or faulted state.
BatchingEnabled
Gets a value indicating whether the batching is enabled.
protected bool BatchingEnabled { get; }
Property Value
- bool
true if batching is enabled; otherwise, false.
Path
Gets the path of the queue or topic relative to the MessagingFactory base address.
public abstract string Path { get; }
Property Value
- string
The path of the queue or topic relative to the MessagingFactory base address.
SupportsGetRuntimeEntityDescription
protected abstract bool SupportsGetRuntimeEntityDescription { get; }
Property Value
Methods
OnBeginCancelScheduledMessage(TrackingContext, IEnumerable<long>, TimeSpan, AsyncCallback, object)
Raises an event that starts the cancellation of the scheduled message.
protected abstract IAsyncResult OnBeginCancelScheduledMessage(TrackingContext trackingContext, IEnumerable<long> sequenceNumbers, TimeSpan timeout, AsyncCallback callback, object state)
Parameters
trackingContext
TrackingContextThe context of the tracking.
sequenceNumbers
IEnumerable<long>The sequence numbers.
timeout
TimeSpanA client side timeout value for the operation. The operation should be aborted or cancelled if the duration exceeds this timeout.
callback
AsyncCallbackA user callback to be invoked when the operation completes.
state
objectThe state to be passed to the callback when the operation completes.
Returns
- IAsyncResult
The asynchronous result of the operation.
OnBeginScheduleMessage(TrackingContext, IEnumerable<BrokeredMessage>, TimeSpan, AsyncCallback, object)
Raises an event when scheduling a message.
protected abstract IAsyncResult OnBeginScheduleMessage(TrackingContext trackingContext, IEnumerable<BrokeredMessage> messages, TimeSpan timeout, AsyncCallback callback, object state)
Parameters
trackingContext
TrackingContextThe context of the tracking.
messages
IEnumerable<BrokeredMessage>The message to schedule.
timeout
TimeSpanA client side timeout value for the operation. The operation should be aborted or cancelled if the duration exceeds this timeout.
callback
AsyncCallbackA user callback to be invoked when the operation completes.
state
objectThe state to be passed to the callback when the operation completes.
Returns
- IAsyncResult
The asynchronous result of the operation.
OnBeginSend(TrackingContext, IEnumerable<BrokeredMessage>, bool, 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.
protected abstract IAsyncResult OnBeginSend(TrackingContext trackingContext, IEnumerable<BrokeredMessage> messages, bool fromSync, TimeSpan timeout, AsyncCallback callback, object state)
Parameters
trackingContext
TrackingContextThe context of the tracking.
messages
IEnumerable<BrokeredMessage>A list of BrokeredMessage objects to be sent.
fromSync
boolThe start of synchronization.
timeout
TimeSpanA client side timeout value for the operation. The operation should be aborted or cancelled if the duration exceeds this timeout.
callback
AsyncCallbackA user callback to be invoked when the operation completes.
state
objectThe state to be passed to the callback when the operation completes.
Returns
- IAsyncResult
A IAsyncResult for the operation.
OnBeginSendEventData(TrackingContext, IEnumerable<EventData>, TimeSpan, AsyncCallback, object)
Raises an event when sending event data.
protected abstract IAsyncResult OnBeginSendEventData(TrackingContext trackingContext, IEnumerable<EventData> eventDatas, TimeSpan timeout, AsyncCallback callback, object state)
Parameters
trackingContext
TrackingContextThe context of the tracking.
eventDatas
IEnumerable<EventData>The event data to send.
timeout
TimeSpanA client side timeout value for the operation. The operation should be aborted or cancelled if the duration exceeds this timeout.
callback
AsyncCallbackA user callback to be invoked when the operation completes.
state
objectThe state to be passed to the callback when the operation completes.
Returns
- IAsyncResult
The asynchronous result of the operation.
OnEndCancelScheduledMessage(IAsyncResult)
Raises an event when ending the cancellation of the scheduled message.
protected abstract void OnEndCancelScheduledMessage(IAsyncResult result)
Parameters
result
IAsyncResultThe result of the operation.
OnEndScheduleMessage(IAsyncResult)
Raises an event when ending the message schedule.
protected abstract IEnumerable<long> OnEndScheduleMessage(IAsyncResult result)
Parameters
result
IAsyncResultThe result of the operation.
Returns
- IEnumerable<long>
The result of the operation.
OnEndSend(IAsyncResult)
Executes the end send action. This method cannot be implemented in a concrete class by the user.
protected abstract void OnEndSend(IAsyncResult result)
Parameters
result
IAsyncResultThe IAsyncResult object created from a call to Microsoft.ServiceBus.Messaging.MessageSender.OnBeginSend(System.Collections.Generic.IEnumerable{Microsoft.ServiceBus.Messaging.BrokeredMessage},System.TimeSpan,System.AsyncCallback,System.Object) method.
OnEndSendEventData(IAsyncResult)
Executes the end send event data action.
protected abstract void OnEndSendEventData(IAsyncResult result)
Parameters
result
IAsyncResultThe result of the operation.
OnSend(TrackingContext, IEnumerable<BrokeredMessage>, TimeSpan)
Allows concrete implementations to override (if needed) what should be done when sending messages in a synchronous manner.
protected virtual void OnSend(TrackingContext trackingContext, IEnumerable<BrokeredMessage> messages, TimeSpan timeout)
Parameters
trackingContext
TrackingContextThe context of the tracking.
messages
IEnumerable<BrokeredMessage>A list of BrokeredMessage objects to be sent.
timeout
TimeSpanA client side timeout value for the operation. The operation should be aborted or cancelled if the duration exceeds this timeout.
Send(BrokeredMessage)
Sends the specified brokered message.
public void Send(BrokeredMessage message)
Parameters
message
BrokeredMessageThe brokered message to send.
Exceptions
- TimeoutException
Thrown when operation times out. Timeout period is initialized through the MessagingFactorySettings. You may need to increase the value of OperationTimeout to avoid this exception if the timeout value is relatively low.
- ArgumentException
Thrown when
message
is null.
SendAsync(BrokeredMessage)
Asynchronously sends the specified brokered message.
public Task SendAsync(BrokeredMessage message)
Parameters
message
BrokeredMessageThe brokered message to send.
Returns
- Task
The asynchronous result of the operation.
SendBatch(IEnumerable<BrokeredMessage>)
Sends a set of brokered messages (for batch processing).
public void SendBatch(IEnumerable<BrokeredMessage> messages)
Parameters
messages
IEnumerable<BrokeredMessage>The collection of brokered messages to send.
SendBatchAsync(IEnumerable<BrokeredMessage>)
Asynchronously sends a set of brokered messages (for batch processing).
public Task SendBatchAsync(IEnumerable<BrokeredMessage> messages)
Parameters
messages
IEnumerable<BrokeredMessage>The collection of brokered messages to send.
Returns
- Task
The asynchronous result of the operation.