Generic Payloads
Experimental
Generic payloads are an experimental feature and the API is subject to change.
When using reactive messaging, Message flow in your system
each message has a payload but can also contain metadata, as explained in Messages, Payload, Metadata.
The metadata can hold information, for example in an outgoing channel, additional properties of the outgoing message to be sent to the broker.
It is sometimes preferable to continue using the payload signatures,
and also being able to attach metadata.
Using GenericPayload allows customizing metadata when handling payloads in SmallRye Reactive Messaging @Incoming and @Outgoing methods.
GenericPayload is a wrapper type, like the Message, containing a payload and metadata,
without requiring handling acknowledgments manually.
You can combine generic payloads with metadata injection :
Note that the metadata provided with the outgoing generic payload is merged with the incoming message metadata.
GenericPayload can also be used with emitters to attach metadata without dealing with Message directly:
The inner payload is extracted and the metadata from the GenericPayload is merged into the outgoing message.
Note that existing metadata entries are not overwritten by the GenericPayload metadata.
If a metadata entry of the same type already exists, it is preserved unless the metadata class implements MergeableMetadata.
Limitations
While GenericPayload<T> can be used as an incoming payload type,
message converters are not applied to the payload type T.