Package com.tnsai.communication
Class AckResult
java.lang.Object
com.tnsai.communication.AckResult
Result of an acknowledgment operation.
Contains the acknowledgment status, timing information, and any error details if the acknowledgment failed.
Usage Example
AckResult result = future.get();
if (result.isAcknowledged()) {
System.out.println("Ack received in " + result.getLatency().toMillis() + "ms");
} else if (result.isTimedOut()) {
System.out.println("Timeout after " + result.getAttempts() + " attempts");
} else {
System.out.println("NACK: " + result.getErrorReason().orElse("Unknown"));
}
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic AckResultacknowledged(String correlationId, Instant sentAt, int attempts, AgentMessage ackMessage) Creates a successful acknowledgment result with attempt count.static AckResultacknowledged(String correlationId, Instant sentAt, AgentMessage ackMessage) Creates a successful acknowledgment result.static AckResultCreates an error result.Returns the acknowledgment message if available.intReturns the number of attempts made.Returns the correlation ID.Returns the error reason if any.Returns the latency (time between send and receive).Returns the time when the acknowledgment was received.Returns the time when the message was sent.Returns the acknowledgment status.booleanChecks if the message was acknowledged positively.booleanisError()Checks if there was an error.booleanChecks if the message was negatively acknowledged.booleanChecks if the acknowledgment timed out.static AckResultnegativeAck(String correlationId, Instant sentAt, String reason, AgentMessage nackMessage) Creates a negative acknowledgment result.static AckResultCreates a timeout result.toString()
-
Method Details
-
acknowledged
Creates a successful acknowledgment result. -
acknowledged
public static AckResult acknowledged(String correlationId, Instant sentAt, int attempts, AgentMessage ackMessage) Creates a successful acknowledgment result with attempt count. -
negativeAck
public static AckResult negativeAck(String correlationId, Instant sentAt, String reason, AgentMessage nackMessage) Creates a negative acknowledgment result. -
timeout
Creates a timeout result. -
error
Creates an error result. -
getCorrelationId
Returns the correlation ID. -
getStatus
Returns the acknowledgment status. -
isAcknowledged
public boolean isAcknowledged()Checks if the message was acknowledged positively. -
isNegativeAck
public boolean isNegativeAck()Checks if the message was negatively acknowledged. -
isTimedOut
public boolean isTimedOut()Checks if the acknowledgment timed out. -
isError
public boolean isError()Checks if there was an error. -
getSentAt
Returns the time when the message was sent. -
getReceivedAt
Returns the time when the acknowledgment was received. -
getLatency
Returns the latency (time between send and receive). -
getAttempts
public int getAttempts()Returns the number of attempts made. -
getErrorReason
Returns the error reason if any. -
getAckMessage
Returns the acknowledgment message if available. -
toString
-