Package io.fluxcapacitor.common.api
Class SerializedMessage
java.lang.Object
io.fluxcapacitor.common.api.SerializedMessage
- All Implemented Interfaces:
HasMetadata
,SerializedObject<byte[]>
Represents a fully serialized message for transmission or storage within the Flux platform.
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
@With
for metadata, segment, etc. - Tracks message origin and target via
source
andtarget
- 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 io.fluxcapacitor.common.api.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.long
getBytes()
Returns the length of bytes in the serialized payload.int
Returns the original revision of the payload object.int
Returns the revision of the serialized object.getType()
Returns the type identifier for the serialized payload.Returns a newSerializedObject
with the given data object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.common.api.HasMetadata
chunked, getMetadata, lastChunk
-
Constructor Details
-
SerializedMessage
-
-
Method Details
-
getOriginalRevision
public int getOriginalRevision()Returns the original revision of the payload object.If
originalRevision
was 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:SerializedObject
Returns the serialized payload held by this object.- Specified by:
data
in interfaceSerializedObject<byte[]>
- Returns:
- the serialized payload
-
withData
Description copied from interface:SerializedObject
Returns a newSerializedObject
with the given data object. If the given data is the same instance as the current one,this
may be returned.- Specified by:
withData
in interfaceSerializedObject<byte[]>
- Parameters:
data
- the new serialized payload- Returns:
- a new
SerializedObject
instance. May bethis
if unchanged
-
getRevision
public int getRevision()Description copied from interface:SerializedObject
Returns the revision of the serialized object.- Specified by:
getRevision
in interfaceSerializedObject<byte[]>
-
getType
Description copied from interface:SerializedObject
Returns the type identifier for the serialized payload.- Specified by:
getType
in interfaceSerializedObject<byte[]>
-
getBytes
public long getBytes()Returns the length of bytes in the serialized payload. If the amount cannot be determined,0
is returned.
-