Class OutgoingKafkaRecord<K,T>
- java.lang.Object
-
- io.smallrye.reactive.messaging.kafka.OutgoingKafkaRecord<K,T>
-
- All Implemented Interfaces:
KafkaRecord<K,T>
,Message<T>
public class OutgoingKafkaRecord<K,T> extends Object implements KafkaRecord<K,T>
-
-
Constructor Summary
Constructors Constructor Description OutgoingKafkaRecord(String topic, K key, T value, Instant timestamp, int partition, org.apache.kafka.common.header.Headers headers, Supplier<CompletionStage<Void>> ack, Function<Throwable,CompletionStage<Void>> nack, Metadata existingMetadata)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletionStage<Void>
ack()
Acknowledge this message.static <K,T>
OutgoingKafkaRecord<K,T>from(Message<T> message)
Supplier<CompletionStage<Void>>
getAck()
org.apache.kafka.common.header.Headers
getHeaders()
K
getKey()
Metadata
getMetadata()
Function<Throwable,CompletionStage<Void>>
getNack()
int
getPartition()
T
getPayload()
Instant
getTimestamp()
String
getTopic()
OutgoingKafkaRecord<K,T>
with(String topic, K key, T value)
OutgoingKafkaRecord<K,T>
with(String topic, K key, T value, Instant timestamp, int partition)
OutgoingKafkaRecord<K,T>
with(String topic, T value)
OutgoingKafkaRecord<K,T>
withAck(Supplier<CompletionStage<Void>> supplier)
Creates a new instance ofMessage
with the given acknowledgement supplier.OutgoingKafkaRecord<K,T>
withHeader(String key, byte[] content)
Creates a new outgoing Kafka Message with a header added to the header list.OutgoingKafkaRecord<K,T>
withHeader(String key, String content)
Creates a new outgoing Kafka Message with a header added to the header list.OutgoingKafkaRecord<K,T>
withHeader(String key, String content, Charset enc)
Creates a new outgoing Kafka Message with a header added to the header list.OutgoingKafkaRecord<K,T>
withMetadata(Iterable<Object> metadata)
Creates a new instance ofMessage
with the specified metadata.OutgoingKafkaRecord<K,T>
withMetadata(Metadata metadata)
Creates a new instance ofMessage
with the specified metadata.OutgoingKafkaRecord<K,T>
withNack(Function<Throwable,CompletionStage<Void>> nack)
Creates a new instance ofMessage
with the given negative-acknowledgement function.<P> OutgoingKafkaRecord<K,P>
withPayload(P payload)
Creates a new instance ofMessage
with the specified payload.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.microprofile.reactive.messaging.Message
addMetadata, getMetadata, nack, unwrap
-
-
-
-
Method Detail
-
from
public static <K,T> OutgoingKafkaRecord<K,T> from(Message<T> message)
-
ack
public CompletionStage<Void> ack()
Description copied from interface:Message
Acknowledge this message.
-
getPayload
public T getPayload()
- Specified by:
getPayload
in interfaceMessage<K>
- Returns:
- The payload for this message.
-
getKey
public K getKey()
- Specified by:
getKey
in interfaceKafkaRecord<K,T>
-
getTopic
public String getTopic()
- Specified by:
getTopic
in interfaceKafkaRecord<K,T>
-
getTimestamp
public Instant getTimestamp()
- Specified by:
getTimestamp
in interfaceKafkaRecord<K,T>
-
getHeaders
public org.apache.kafka.common.header.Headers getHeaders()
- Specified by:
getHeaders
in interfaceKafkaRecord<K,T>
-
getAck
public Supplier<CompletionStage<Void>> getAck()
- Specified by:
getAck
in interfaceMessage<K>
- Returns:
- the supplier used to retrieve the acknowledgement
CompletionStage
.
-
getNack
public Function<Throwable,CompletionStage<Void>> getNack()
-
getPartition
public int getPartition()
- Specified by:
getPartition
in interfaceKafkaRecord<K,T>
-
getMetadata
public Metadata getMetadata()
- Specified by:
getMetadata
in interfaceMessage<K>
- Returns:
- The set of metadata attached to this message, potentially empty.
-
withHeader
public OutgoingKafkaRecord<K,T> withHeader(String key, byte[] content)
Creates a new outgoing Kafka Message with a header added to the header list.- Parameters:
key
- the header keycontent
- the header key, must not benull
- Returns:
- the updated Kafka Message.
-
withHeader
public OutgoingKafkaRecord<K,T> withHeader(String key, String content)
Creates a new outgoing Kafka Message with a header added to the header list.- Parameters:
key
- the header keycontent
- the header key, must not benull
- Returns:
- the updated Kafka Message.
-
withHeader
public OutgoingKafkaRecord<K,T> withHeader(String key, String content, Charset enc)
Creates a new outgoing Kafka Message with a header added to the header list.- Parameters:
key
- the header keycontent
- the header key, must not benull
enc
- the encoding, must not benull
- Returns:
- the updated Kafka Message.
-
with
public OutgoingKafkaRecord<K,T> with(String topic, T value)
-
with
public OutgoingKafkaRecord<K,T> with(String topic, K key, T value, Instant timestamp, int partition)
-
withPayload
public <P> OutgoingKafkaRecord<K,P> withPayload(P payload)
Description copied from interface:Message
Creates a new instance ofMessage
with the specified payload. The metadata and ack/nack functions are taken from the currentMessage
.- Specified by:
withPayload
in interfaceMessage<K>
- Type Parameters:
P
- the type of the new payload- Parameters:
payload
- the new payload.- Returns:
- the new instance of
Message
-
withMetadata
public OutgoingKafkaRecord<K,T> withMetadata(Iterable<Object> metadata)
Description copied from interface:Message
Creates a new instance ofMessage
with the specified metadata. The payload and ack/nack functions are taken from the currentMessage
.- Specified by:
withMetadata
in interfaceMessage<K>
- Parameters:
metadata
- the metadata, must not benull
, must not containsnull
.- Returns:
- the new instance of
Message
-
withMetadata
public OutgoingKafkaRecord<K,T> withMetadata(Metadata metadata)
Description copied from interface:Message
Creates a new instance ofMessage
with the specified metadata. The payload and ack/nack functions are taken from the currentMessage
.- Specified by:
withMetadata
in interfaceMessage<K>
- Parameters:
metadata
- the metadata, must not benull
.- Returns:
- the new instance of
Message
-
withAck
public OutgoingKafkaRecord<K,T> withAck(Supplier<CompletionStage<Void>> supplier)
Description copied from interface:Message
-
withNack
public OutgoingKafkaRecord<K,T> withNack(Function<Throwable,CompletionStage<Void>> nack)
Description copied from interface:Message
-
-