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.
|
default Supplier<CompletionStage<Void>> |
getAck() |
default Function<Throwable,CompletionStage<Void>> |
getNack() |
T |
getPayload() |
default CompletionStage<Void> |
nack(Throwable reason)
Acknowledge negatively this message.
|
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.
|
static <T> Message<T> |
of(T payload,
Supplier<CompletionStage<Void>> ack,
Function<Throwable,CompletionStage<Void>> nack)
Create a message with the given payload, ack and nack functions.
|
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. |
default Message<T> |
withAck(Supplier<CompletionStage<Void>> ack)
Creates a new instance of
Message with the given acknowledgement supplier. |
default Message<T> |
withNack(Function<Throwable,CompletionStage<Void>> nack)
Creates a new instance of
Message with the given negative-acknowledgement function. |
default <P> Message<P> |
withPayload(P payload)
Creates a new instance of
Message with the specified payload. |
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.static <T> Message<T> of(T payload, Supplier<CompletionStage<Void>> ack, Function<Throwable,CompletionStage<Void>> nack)
T - the type of payloadpayload - The payload.ack - The ack function, this will be invoked when the returned messages ack() method is invoked.nack - The negative-ack function, this will be invoked when the returned messages nack(Throwable)
method is invoked.default <P> Message<P> withPayload(P payload)
Message with the specified payload. The ack/nack functions are taken from the
current Message.P - the type of the new payloadpayload - the new payload.Messagedefault Message<T> withAck(Supplier<CompletionStage<Void>> ack)
Message with the given acknowledgement supplier. The payload, and nack function
are taken from the current Message.ack - the positive-acknowledgement functionMessagedefault Message<T> withNack(Function<Throwable,CompletionStage<Void>> nack)
Message with the given negative-acknowledgement function. The payload and
acknowledgment are taken from the current Message.nack - the negative-acknowledgement functionMessageT getPayload()
default CompletionStage<Void> ack()
default Supplier<CompletionStage<Void>> getAck()
CompletionStage.default Function<Throwable,CompletionStage<Void>> getNack()
default CompletionStage<Void> nack(Throwable reason)
nack is used to indicate that the processing of a message
failed with the reason passed as the parameter.reason - the reason of the nack, must not be nulldefault <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 – 2022 Eclipse Foundation. All rights reserved.
Use is subject to license terms.