Type Parameters:
K - the type of Kafka record key
V - the type of Kafka record value
All Superinterfaces:
Message<V>
All Known Implementing Classes:
KafkaProducerMessage

public interface KafkaMessage<K,V> extends Message<V>
Kafka specific Micro Profile Reactive Messaging Message.
  • Method Details

    • getTopic

      Optional<String> getTopic()
      Name of the topic from which was this message received.
      Returns:
      topic name
    • getPartition

      Optional<Integer> getPartition()
      Number of partition from which was this message received.
      Returns:
      partition number
    • getOffset

      Optional<Long> getOffset()
      Offset of the record in partition from which was this message received.
      Returns:
      offset number
    • getConsumerRecord

      Optional<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>> getConsumerRecord()
      Returns ConsumerRecord if message was received from Kafka, otherwise return Optional.empty().
      Returns:
      ConsumerRecord or Optional.empty()
    • getKey

      Optional<K> getKey()
      Key or Optional.empty() if non is specified.
      Returns:
      Key or Optional.empty()
    • getHeaders

      org.apache.kafka.common.header.Headers getHeaders()
      Returns Headers received from Kafka with record or empty headers if message was not created by Kafka connector.
      Returns:
      Headers received from Kafka or empty headers if message was not created by Kafka connector
    • of

      static <K, V> KafkaMessage<K,V> of(K key, V payload, Supplier<CompletionStage<Void>> ack)
      Create a message with the given payload and ack function.
      Type Parameters:
      K - the type of Kafka record key
      V - the type of Kafka record value
      Parameters:
      key - Kafka record key
      payload - Kafka record value
      ack - The ack function, this will be invoked when the returned messages Message.ack() method is invoked
      Returns:
      A message with the given payload and ack function
    • of

      static <K, V> KafkaMessage<K,V> of(V payload, Supplier<CompletionStage<Void>> ack)
      Create a message with the given payload and ack function.
      Type Parameters:
      K - the type of Kafka record key
      V - the type of Kafka record value
      Parameters:
      payload - Kafka record value
      ack - The ack function, this will be invoked when the returned messages Message.ack() method is invoked
      Returns:
      A message with the given payload and ack function
    • of

      static <K, V> KafkaMessage<K,V> of(K key, V payload)
      Create a message with the given payload and ack function.
      Type Parameters:
      K - the type of Kafka record key
      V - the type of Kafka record value
      Parameters:
      key - Kafka record key
      payload - Kafka record value
      Returns:
      A message with the given payload and ack function
    • of

      static <K, V> KafkaMessage<K,V> of(V payload)
      Create a message with the given payload and ack function.
      Type Parameters:
      K - the type of Kafka record key
      V - the type of Kafka record value
      Parameters:
      payload - Kafka record value
      Returns:
      A message with the given payload and ack function