Class KafkaMetadataUtil
- java.lang.Object
-
- io.smallrye.reactive.messaging.kafka.api.KafkaMetadataUtil
-
public class KafkaMetadataUtil extends Object
Utility to accessKafkaMessageMetadata
in aMessage
.
-
-
Constructor Summary
Constructors Constructor Description KafkaMetadataUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Optional<IncomingKafkaRecordMetadata>
readIncomingKafkaMetadata(Message<?> msg)
ReadIncomingKafkaRecordMetadata
from aMessage
.static <T,K>
Message<T>writeOutgoingKafkaMetadata(Message<T> msg, OutgoingKafkaRecordMetadata<K> outgoingKafkaRecordMetadata)
WriteOutgoingKafkaRecordMetadata
to aMessage
.
-
-
-
Method Detail
-
readIncomingKafkaMetadata
public static Optional<IncomingKafkaRecordMetadata> readIncomingKafkaMetadata(Message<?> msg)
ReadIncomingKafkaRecordMetadata
from aMessage
.- Parameters:
msg
- the message. Must not benull
- Returns:
- The
IncomingKafkaRecordMetadata
. May returnnull
, for example if the message is not received from a channel backed by Kafka - Throws:
NullPointerException
- ifmsg
isnull
-
writeOutgoingKafkaMetadata
public static <T,K> Message<T> writeOutgoingKafkaMetadata(Message<T> msg, OutgoingKafkaRecordMetadata<K> outgoingKafkaRecordMetadata)
WriteOutgoingKafkaRecordMetadata
to aMessage
. Note thatMessage
is immutable, so the passed in parameter will not have theOutgoingKafkaRecordMetadata
added. This method returns a new instance ofMessage
with theOutgoingKafkaRecordMetadata
added.- Parameters:
msg
- the message. Must not benull
outgoingKafkaRecordMetadata
- theOutgoingKafkaRecordMetadata
to write. Must not benull
- Returns:
- a clone of with the
OutgoingKafkaRecordMetadata
added - Throws:
NullPointerException
- ifmsg
oroutgoingKafkaRecordMetadata
arenull
-
-