T - The type of the message payload.public interface Message<T>
Messaging providers may provide their own sub classes of this type, in order to allow messaging provider specific information to be passed to and from applications.
| Modifier and Type | Method and Description |
|---|---|
default CompletionStage<Void> |
ack()
Acknowledge this message.
|
T |
getPayload() |
static <T> Message<T> |
of(T payload)
Create a message with the given payload.
|
static <T> Message<T> |
of(T payload,
Supplier<CompletionStage<Void>> ack)
Create a message with the given payload and ack function.
|
default <C> C |
unwrap(Class<C> unwrapType)
Returns an object of the specified type to allow access to the connector-specific
Message implementation,
and other classes. |
static <T> Message<T> of(T payload)
T - The type of payloadpayload - The payload.static <T> Message<T> of(T payload, Supplier<CompletionStage<Void>> ack)
T - the type of payloadpayload - The payload.ack - The ack function, this will be invoked when the returned messages ack() method is invoked.T getPayload()
default CompletionStage<Void> ack()
default <C> C unwrap(Class<C> unwrapType)
Message implementation,
and other classes. For example, a Kafka connector could implement this method to allow unwrapping to a specific
Kafka message implementation, or to ConsumerRecord and ProducerRecord. If the Message
implementation does not support the target class, an IllegalArgumentException should be raised.
The default implementation tries to cast the current Message instance to the target class.
When a connector provides its own Message implementation, it should override this method to support
specific types.C - the target typeunwrapType - the class of the object to be returned, must not be nullIllegalArgumentException - if the current Message instance does not support the callCopyright © 2018–2019 Eclipse Foundation. All rights reserved.