Class MessagingClient
Represents typed client for sending messages to the nodes in the cluster.
Inherited Members
Namespace: DotNext.Net.Cluster.Messaging
Assembly: DotNext.Net.Cluster.dll
Syntax
public class MessagingClient
Constructors
| Edit this page View SourceMessagingClient(IOutputChannel)
Constructs a new typed client for messaging.
Declaration
public MessagingClient(IOutputChannel channel)
Parameters
Type | Name | Description |
---|---|---|
IOutputChannel | channel | The output channel for outbound messages. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Methods
| Edit this page View SourceGetMessageInfo<TMessage>()
Gets the name of MIME type by message type.
Declaration
protected virtual (string MessageName, ContentType MessageType) GetMessageInfo<TMessage>() where TMessage : notnull, ISerializable<TMessage>
Returns
Type | Description |
---|---|
(string MessageName, ContentType MessageType) | The message name and MIME type. |
Type Parameters
Name | Description |
---|---|
TMessage | The type of the message. |
Exceptions
Type | Condition |
---|---|
GenericArgumentException<T> |
|
RegisterMessage<TMessage>(MessageAttribute<TMessage>)
Registers message type and its type.
Declaration
public MessagingClient RegisterMessage<TMessage>(MessageAttribute<TMessage> messageInfo) where TMessage : notnull, ISerializable<TMessage>
Parameters
Type | Name | Description |
---|---|---|
MessageAttribute<TMessage> | messageInfo | The information about message type. |
Returns
Type | Description |
---|---|
MessagingClient | This client. |
Type Parameters
Name | Description |
---|---|
TMessage | The type of the message payload. |
RegisterMessage<TMessage>(string, ContentType?)
Registers message type and its type.
Declaration
public MessagingClient RegisterMessage<TMessage>(string name, ContentType? type = null) where TMessage : notnull, ISerializable<TMessage>
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the message. |
ContentType | type | MIME type of the message. |
Returns
Type | Description |
---|---|
MessagingClient | This client. |
Type Parameters
Name | Description |
---|---|
TMessage | The type of the message payload. |
SendMessageAsync<TInput, TOutput>(TInput, CancellationToken)
Sends a request message.
Declaration
public Task<TOutput> SendMessageAsync<TInput, TOutput>(TInput input, CancellationToken token = default) where TInput : notnull, ISerializable<TInput> where TOutput : notnull, ISerializable<TOutput>
Parameters
Type | Name | Description |
---|---|---|
TInput | input | The request. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task<TOutput> | The response. |
Type Parameters
Name | Description |
---|---|
TInput | The type of the request. |
TOutput | The type of the response. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Attempts to send message to local or unavailable endpoint. |
OperationCanceledException | The operation has been canceled. |
SendSignalAsync<TInput>(TInput, CancellationToken)
Sends one-way message.
Declaration
public Task SendSignalAsync<TInput>(TInput input, CancellationToken token = default) where TInput : notnull, ISerializable<TInput>
Parameters
Type | Name | Description |
---|---|---|
TInput | input | The message to send. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task | The task representing asynchronous execution of this method. |
Type Parameters
Name | Description |
---|---|
TInput | The type of the message. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Attempts to send message to local or unavailable endpoint. |
OperationCanceledException | The operation has been canceled. |