Class KafkaMetadataUtil

java.lang.Object
io.smallrye.reactive.messaging.kafka.api.KafkaMetadataUtil

public class KafkaMetadataUtil extends Object
Utility to access KafkaMessageMetadata in a Message.
  • Constructor Details

    • KafkaMetadataUtil

      public KafkaMetadataUtil()
  • Method Details

    • readIncomingKafkaMetadata

      public static Optional<IncomingKafkaRecordMetadata> readIncomingKafkaMetadata(org.eclipse.microprofile.reactive.messaging.Message<?> msg)
      Read IncomingKafkaRecordMetadata from a Message.
      Parameters:
      msg - the message. Must not be null
      Returns:
      The IncomingKafkaRecordMetadata. May return null, for example if the message is not received from a channel backed by Kafka
      Throws:
      NullPointerException - if msg is null
    • writeOutgoingKafkaMetadata

      public static <T, K> org.eclipse.microprofile.reactive.messaging.Message<T> writeOutgoingKafkaMetadata(org.eclipse.microprofile.reactive.messaging.Message<T> msg, OutgoingKafkaRecordMetadata<K> outgoingKafkaRecordMetadata)
      Write OutgoingKafkaRecordMetadata to a Message. Note that Message is immutable, so the passed in parameter will not have the OutgoingKafkaRecordMetadata added. This method returns a new instance of Message with the OutgoingKafkaRecordMetadata added.
      Parameters:
      msg - the message. Must not be null
      outgoingKafkaRecordMetadata - the OutgoingKafkaRecordMetadata to write. Must not be null
      Returns:
      a clone of with the OutgoingKafkaRecordMetadata added
      Throws:
      NullPointerException - if msg or outgoingKafkaRecordMetadata are null