Package com.tnsai.spi
Record Class MessageBroker.Message
java.lang.Object
java.lang.Record
com.tnsai.spi.MessageBroker.Message
- Enclosing interface:
MessageBroker
public static record MessageBroker.Message(String id, String from, String to, String topic, Object payload, Map<String,Object> headers, long timestamp)
extends Record
Message container for inter-agent communication.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.from()Returns the value of thefromrecord component.static MessageBroker.MessageCreates a message with sender and payload.final inthashCode()Returns a hash code value for this object.headers()Returns the value of theheadersrecord component.id()Returns the value of theidrecord component.static MessageBroker.MessageCreates a simple message with payload only.payload()Returns the value of thepayloadrecord component.Creates a reply to this message.longReturns the value of thetimestamprecord component.to()Returns the value of thetorecord component.static MessageBroker.MessageCreates a directed message.topic()Returns the value of thetopicrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Message
public Message(String id, String from, String to, String topic, Object payload, Map<String, Object> headers, long timestamp) Creates an instance of aMessagerecord class.- Parameters:
id- the value for theidrecord componentfrom- the value for thefromrecord componentto- the value for thetorecord componenttopic- the value for thetopicrecord componentpayload- the value for thepayloadrecord componentheaders- the value for theheadersrecord componenttimestamp- the value for thetimestamprecord component
-
-
Method Details
-
of
Creates a simple message with payload only. -
from
Creates a message with sender and payload. -
to
Creates a directed message. -
reply
Creates a reply to this message. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
from
Returns the value of thefromrecord component.- Returns:
- the value of the
fromrecord component
-
to
Returns the value of thetorecord component.- Returns:
- the value of the
torecord component
-
topic
Returns the value of thetopicrecord component.- Returns:
- the value of the
topicrecord component
-
payload
Returns the value of thepayloadrecord component.- Returns:
- the value of the
payloadrecord component
-
headers
Returns the value of theheadersrecord component.- Returns:
- the value of the
headersrecord component
-
timestamp
public long timestamp()Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-