Show / Hide Table of Contents

Interface IProducer

Defines the contract for a message producer that creates and sends messages to queues or topics in a messaging system. Provides asynchronous methods for message creation, sending, and transaction management. Implementations are expected to be safe for concurrent use and to honor cancellation semantics where applicable.

Namespace: CodersRealm.NmsAmqpClient
Assembly: CodersRealm.NmsAmqpClient.dll
Syntax
public interface IProducer

Properties

IsDisposed

Gets a value indicating whether this producer has been disposed and is no longer usable.

Declaration
bool IsDisposed { get; }
Property Value
Type Description
bool

IsRunning

Gets a value indicating whether the producer is currently running and able to send messages.

Declaration
bool IsRunning { get; }
Property Value
Type Description
bool

Tag

Gets a unique identifier for this producer instance. Useful for diagnostics and logging.

Declaration
Guid Tag { get; }
Property Value
Type Description
Guid

Methods

CommitAsync()

Commits the current transaction, if the producer is operating in a transactional mode.

Declaration
Task CommitAsync()
Returns
Type Description
Task

A task that completes when the commit operation has finished.

CreateBytesMessageAsync()

Creates a new bytes message instance asynchronously.

Declaration
Task<IBytesMessage> CreateBytesMessageAsync()
Returns
Type Description
Task<IBytesMessage>

A task that completes with the created Apache.NMS.IBytesMessage.

CreateBytesMessageAsync(byte[])

Asynchronously creates a new bytes message with the specified body.

Declaration
Task<IBytesMessage> CreateBytesMessageAsync(byte[] body)
Parameters
Type Name Description
byte[] body

The byte array containing the message payload. Cannot be null.

Returns
Type Description
Task<IBytesMessage>

A task that represents the asynchronous operation. The task result contains an Apache.NMS.IBytesMessage instance initialized with the specified body.

CreateMapMessageAsync()

Creates a new map message instance asynchronously.

Declaration
Task<IMapMessage> CreateMapMessageAsync()
Returns
Type Description
Task<IMapMessage>

A task that completes with the created Apache.NMS.IMapMessage.

CreateMessageAsync()

Creates a generic message instance asynchronously.

Declaration
Task<IMessage> CreateMessageAsync()
Returns
Type Description
Task<IMessage>

A task that completes with the created Apache.NMS.IMessage.

CreateObjectMessageAsync(object)

Creates an object message that wraps the provided object instance.

Declaration
Task<IObjectMessage> CreateObjectMessageAsync(object dataObject)
Parameters
Type Name Description
object dataObject

The object to include in the message payload.

Returns
Type Description
Task<IObjectMessage>

A task that completes with the created Apache.NMS.IObjectMessage.

CreateStreamMessageAsync()

Creates a stream message instance asynchronously.

Declaration
Task<IStreamMessage> CreateStreamMessageAsync()
Returns
Type Description
Task<IStreamMessage>

A task that completes with the created Apache.NMS.IStreamMessage.

CreateTemporaryQueueAsync()

Creates a temporary queue for use by this producer. The returned queue may be null if the underlying provider does not support temporary destinations.

Declaration
Task<ITemporaryQueue?> CreateTemporaryQueueAsync()
Returns
Type Description
Task<ITemporaryQueue>

A task that completes with the created Apache.NMS.ITemporaryQueue, or null if not supported.

CreateTemporaryTopicAsync()

Creates a temporary topic for use by this producer. The returned topic may be null if the underlying provider does not support temporary destinations.

Declaration
Task<ITemporaryTopic?> CreateTemporaryTopicAsync()
Returns
Type Description
Task<ITemporaryTopic>

A task that completes with the created Apache.NMS.ITemporaryTopic, or null if not supported.

CreateTextMessageAsync()

Creates an empty text message instance asynchronously.

Declaration
Task<ITextMessage> CreateTextMessageAsync()
Returns
Type Description
Task<ITextMessage>

A task that completes with the created Apache.NMS.ITextMessage.

CreateTextMessageAsync(string)

Creates a text message with the provided text content asynchronously.

Declaration
Task<ITextMessage> CreateTextMessageAsync(string text)
Parameters
Type Name Description
string text

The text content for the message.

Returns
Type Description
Task<ITextMessage>

A task that completes with the created Apache.NMS.ITextMessage.

GetQueueAsync(string)

Retrieves a queue by name from the messaging provider. Returns null if the queue cannot be found or created by the provider.

Declaration
Task<IQueue?> GetQueueAsync(string queueName)
Parameters
Type Name Description
string queueName

The name of the queue to retrieve.

Returns
Type Description
Task<IQueue>

A task that completes with the Apache.NMS.IQueue instance or null.

GetTopicAsync(string)

Retrieves a topic by name from the messaging provider. Returns null if the topic cannot be found or created by the provider.

Declaration
Task<ITopic?> GetTopicAsync(string topicName)
Parameters
Type Name Description
string topicName

The name of the topic to retrieve.

Returns
Type Description
Task<ITopic>

A task that completes with the Apache.NMS.ITopic instance or null.

RollbackAsync()

Rolls back the current transaction, if the producer is operating in a transactional mode.

Declaration
Task RollbackAsync()
Returns
Type Description
Task

A task that completes when the rollback operation has finished.

SendMessageAsync(IMessage)

Sends a message using the producer's default destination and delivery settings.

Declaration
Task SendMessageAsync(IMessage message)
Parameters
Type Name Description
IMessage message

The message to send.

Returns
Type Description
Task

A task that completes when the send operation has finished.

SendMessageAsync(IMessage, IDestination)

Sends a message to a specific destination instance.

Declaration
Task SendMessageAsync(IMessage message, IDestination destination)
Parameters
Type Name Description
IMessage message

The message to send.

IDestination destination

The destination to send the message to.

Returns
Type Description
Task

A task that completes when the send operation has finished.

SendMessageAsync(IMessage, IDestination, MsgDeliveryMode, MsgPriority, TimeSpan)

Sends a message to a specific destination instance with explicit delivery settings.

Declaration
Task SendMessageAsync(IMessage message, IDestination destination, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive)
Parameters
Type Name Description
IMessage message

The message to send.

IDestination destination

The destination to send the message to.

MsgDeliveryMode deliveryMode

The delivery mode to use for the message.

MsgPriority priority

The priority to use for the message.

TimeSpan timeToLive

The time-to-live for the message.

Returns
Type Description
Task

A task that completes when the send operation has finished.

SendMessageAsync(IMessage, MsgDeliveryMode, MsgPriority, TimeSpan)

Sends a message with explicit delivery mode, priority, and time-to-live settings.

Declaration
Task SendMessageAsync(IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive)
Parameters
Type Name Description
IMessage message

The message to send.

MsgDeliveryMode deliveryMode

The delivery mode to use for the message.

MsgPriority priority

The priority to use for the message.

TimeSpan timeToLive

The time-to-live for the message.

Returns
Type Description
Task

A task that completes when the send operation has finished.

SendMessageAsync(IMessage, string, DestinationType)

Sends a message to a destination identified by name and type (queue or topic).

Declaration
Task SendMessageAsync(IMessage message, string destinationName, DestinationType destinationType)
Parameters
Type Name Description
IMessage message

The message to send.

string destinationName

The name of the destination (queue or topic).

DestinationType destinationType

The type of the destination.

Returns
Type Description
Task

A task that completes when the send operation has finished.

SendMessageAsync(IMessage, string, DestinationType, MsgDeliveryMode, MsgPriority, TimeSpan)

Sends a message to a destination identified by name and type using explicit delivery settings.

Declaration
Task SendMessageAsync(IMessage message, string destinationName, DestinationType destinationType, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive)
Parameters
Type Name Description
IMessage message

The message to send.

string destinationName

The name of the destination (queue or topic).

DestinationType destinationType

The type of the destination.

MsgDeliveryMode deliveryMode

The delivery mode to use for the message.

MsgPriority priority

The priority to use for the message.

TimeSpan timeToLive

The time-to-live for the message.

Returns
Type Description
Task

A task that completes when the send operation has finished.

In this article
Back to top Generated by DocFX