Interface KafkaMessage<K,V>
-
- Type Parameters:
K
- the type of Kafka record keyV
- 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 Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>
getConsumerRecord()
ReturnsConsumerRecord
if message was received from Kafka, otherwise returnOptional.empty()
.org.apache.kafka.common.header.Headers
getHeaders()
ReturnsHeaders
received from Kafka with record or empty headers if message was not created by Kafka connector.Optional<K>
getKey()
Key orOptional.empty()
if non is specified.Optional<Long>
getOffset()
Offset of the record in partition from which was this message received.Optional<Integer>
getPartition()
Number of partition from which was this message received.Optional<String>
getTopic()
Name of the topic from which was this message received.static <K,V>
KafkaMessage<K,V>of(K key, V payload)
Create a message with the given payload and ack function.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.static <K,V>
KafkaMessage<K,V>of(V payload)
Create a message with the given payload and ack function.static <K,V>
KafkaMessage<K,V>of(V payload, Supplier<CompletionStage<Void>> ack)
Create a message with the given payload and ack function.-
Methods inherited from interface org.eclipse.microprofile.reactive.messaging.Message
ack, getPayload, unwrap
-
-
-
-
Method Detail
-
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()
ReturnsConsumerRecord
if message was received from Kafka, otherwise returnOptional.empty()
.- Returns:
ConsumerRecord
orOptional.empty()
-
getKey
Optional<K> getKey()
Key orOptional.empty()
if non is specified.- Returns:
- Key or
Optional.empty()
-
getHeaders
org.apache.kafka.common.header.Headers getHeaders()
ReturnsHeaders
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 keyV
- the type of Kafka record value- Parameters:
key
- Kafka record keypayload
- Kafka record valueack
- The ack function, this will be invoked when the returned messagesMessage.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 keyV
- the type of Kafka record value- Parameters:
payload
- Kafka record valueack
- The ack function, this will be invoked when the returned messagesMessage.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 keyV
- the type of Kafka record value- Parameters:
key
- Kafka record keypayload
- 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 keyV
- the type of Kafka record value- Parameters:
payload
- Kafka record value- Returns:
- A message with the given payload and ack function
-
-