Class SerializedMessage
java.lang.Object
io.fluxzero.common.api.SerializedMessage
- All Implemented Interfaces:
HasMetadata, SerializedObject<byte[]>
Represents a fully serialized message for transmission or storage within the Fluxzero Runtime.
A SerializedMessage wraps the binary Data of a message payload, along with associated
Metadata and optional routing and tracking information such as index, segment, and
requestId.
This class is the wire format and persistence format for messages. It implements SerializedObject to expose
type and revision metadata, and HasMetadata to allow downstream access to structured metadata.
Key Features
- Encapsulates payload as serialized
byte[]viaData - Immutable-style updates via
@Withfor metadata, segment, etc. - Tracks message origin and target via
sourceandtarget - Supports custom revision control via
originalRevision, set before upcasting
Tracking Fields
- segment – the segment of the message log this message belongs to (used for partitioning)
- index – the index of this message in the log, used for ordering and deduplication
- requestId – identifier that ties a response to its originating request
Typical Use
Serialized messages are produced by serializing aMessage using a Serializer,
and are then stored, indexed, transmitted, or routed based on metadata and log location.- See Also:
-
Field Summary
Fields inherited from interface HasMetadata
FINAL_CHUNK -
Constructor Summary
ConstructorsConstructorDescriptionSerializedMessage(Data<byte[]> data, Metadata metadata, String messageId, Long timestamp) -
Method Summary
Modifier and TypeMethodDescriptionData<byte[]> data()Returns the serialized payload held by this object.longgetBytes()Returns the length of bytes in the serialized payload.intReturns the original revision of the payload object.intReturns the revision of the serialized object.getType()Returns the type identifier for the serialized payload.Returns a newSerializedObjectwith the given data object.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HasMetadata
chunked, getMetadata, lastChunk
-
Constructor Details
-
SerializedMessage
-
-
Method Details
-
getOriginalRevision
public int getOriginalRevision()Returns the original revision of the payload object.If
originalRevisionwas explicitly set before upcasting, it is returned. Otherwise, the revision is delegated toSerializedObject.getRevision().- Returns:
- the original revision of the serialized payload
-
data
Description copied from interface:SerializedObjectReturns the serialized payload held by this object.- Specified by:
datain interfaceSerializedObject<byte[]>- Returns:
- the serialized payload
-
withData
Description copied from interface:SerializedObjectReturns a newSerializedObjectwith the given data object. If the given data is the same instance as the current one,thismay be returned.- Specified by:
withDatain interfaceSerializedObject<byte[]>- Parameters:
data- the new serialized payload- Returns:
- a new
SerializedObjectinstance. May bethisif unchanged
-
getRevision
public int getRevision()Description copied from interface:SerializedObjectReturns the revision of the serialized object.- Specified by:
getRevisionin interfaceSerializedObject<byte[]>
-
getType
Description copied from interface:SerializedObjectReturns the type identifier for the serialized payload.- Specified by:
getTypein interfaceSerializedObject<byte[]>
-
getBytes
public long getBytes()Returns the length of bytes in the serialized payload. If the amount cannot be determined,0is returned.
-