Struct MessageBrokerListenerCallbackArgs
- Namespace
- LfrlAnvil.MessageBroker.Client
- Assembly
- LfrlAnvil.MessageBroker.Client.dll
Represents a set of attributes that defines a single message received from the server.
public readonly struct MessageBrokerListenerCallbackArgs
- Inherited Members
Properties
AckId
Id of the ACK associated with the message.
public int AckId { get; }
Property Value
Remarks
ACK is expected only when value is greater than 0. Value equal to -1 specifies that this message is from a dead letter.
Data
Binary data of this message.
public ReadOnlyMemory<byte> Data { get; }
Property Value
IsFirst
Specifies whether this message is not a retry and not a redelivery.
public bool IsFirst { get; }
Property Value
IsFromDeadLetter
Specifies whether this message is from a dead letter.
public bool IsFromDeadLetter { get; }
Property Value
IsRedelivery
Specifies whether this message is a redelivery.
public bool IsRedelivery { get; }
Property Value
IsRetry
Specifies whether this message is a retry.
public bool IsRetry { get; }
Property Value
Listener
MessageBrokerListener that received this message.
public MessageBrokerListener Listener { get; }
Property Value
MessageId
Message's unique identifier assigned by the server.
public ulong MessageId { get; }
Property Value
PushedAt
Moment of registration of this message in the server-side stream.
public Timestamp PushedAt { get; }
Property Value
ReceivedAt
Moment when the client has received this message.
public Timestamp ReceivedAt { get; }
Property Value
Redelivery
Redelivery attempt of this message.
public int Redelivery { get; }
Property Value
Remarks
Redeliveries are initiated automatically by the server when clients fail to respond with either ACK or negative ACK in time.
Retry
Retry attempt of this message.
public int Retry { get; }
Property Value
Remarks
Retries are initiated by sending NACK response to the server.
Sender
Client that published this message.
public MessageBrokerExternalObject Sender { get; }
Property Value
Stream
Server-side stream that handled this message.
public MessageBrokerExternalObject Stream { get; }
Property Value
TraceId
Identifier of an internal event trace, with which this message is correlated to.
public ulong TraceId { get; }
Property Value
Remarks
Can be used to correlate this message with events emitted by MessageBrokerClient's logger.
Methods
AckAsync()
Attempts to send a message notification ACK for this message.
public ValueTask<Result<bool>> AckAsync()
Returns
- ValueTask<Result<bool>>
A task that represents the operation, which returns a Result<T> instance, with underlying bool result. If the result is equal to true, then ACK sending was successful, otherwise the Listener was no longer bound to the channel.
Remarks
Unexpected errors encountered during ACK sending attempt will cause the client to be automatically disposed. Returned Result<T> will only be valid when either the client has successfully sent the ACK to the server, or the Listener is already locally ubound from the channel, which will cancel the request to the server.
Exceptions
- MessageBrokerClientDisposedException
When client has already been disposed.
- MessageBrokerClientMessageException
When ACKs are not enabled for the Listener.
- ArgumentOutOfRangeException
When IsFromDeadLetter is equal to true.
NegativeAckAsync(MessageBrokerNegativeAck)
Attempts to send a negative message notification ACK for this message.
public ValueTask<Result<bool>> NegativeAckAsync(MessageBrokerNegativeAck nack = default)
Parameters
nackMessageBrokerNegativeAckOptional MessageBrokerNegativeAck instance that allows to modify the ACK. Equal to Default by default.
Returns
- ValueTask<Result<bool>>
A task that represents the operation, which returns a Result<T> instance, with underlying bool result. If the result is equal to true, then ACK sending was successful, otherwise the Listener was no longer bound to the channel.
Remarks
Unexpected errors encountered during ACK sending attempt will cause the client to be automatically disposed. Returned Result<T> will only be valid when either the client has successfully sent the ACK to the server, or the Listener is already locally ubound from the channel, which will cancel the request to the server.
Exceptions
- MessageBrokerClientDisposedException
When client has already been disposed.
- MessageBrokerClientMessageException
When ACKs are not enabled for the Listener.
- ArgumentOutOfRangeException
When IsFromDeadLetter is equal to true.
ToString()
Returns a string representation of this MessageBrokerListenerCallbackArgs instance.
[Pure]
public override string ToString()
Returns
- string
String representation.