K - the key type.V - the value type.S - the KafkaProducerMessageHandlerSpec extension type.public class KafkaProducerMessageHandlerSpec<K,V,S extends KafkaProducerMessageHandlerSpec<K,V,S>> extends org.springframework.integration.dsl.MessageHandlerSpec<S,KafkaProducerMessageHandler<K,V>>
MessageHandlerSpec implementation for the KafkaProducerMessageHandler.| Modifier and Type | Class and Description |
|---|---|
static class |
KafkaProducerMessageHandlerSpec.KafkaProducerMessageHandlerTemplateSpec<K,V>
A
KafkaTemplate-based KafkaProducerMessageHandlerSpec extension. |
static class |
KafkaProducerMessageHandlerSpec.KafkaTemplateSpec<K,V>
An
IntegrationComponentSpec implementation for the KafkaTemplate. |
| Modifier and Type | Method and Description |
|---|---|
<P> S |
messageKey(java.util.function.Function<org.springframework.messaging.Message<P>,?> messageKeyFunction)
Configure a
Function that will be invoked at run time to determine the message key under
which a message will be stored in the topic. |
S |
messageKey(java.lang.String messageKey)
Configure the message key to store message in Kafka topic.
|
S |
messageKeyExpression(org.springframework.expression.Expression messageKeyExpression)
Configure an
Expression to determine the Kafka message key to store at runtime against
request Message as a root object of evaluation context. |
S |
messageKeyExpression(java.lang.String messageKeyExpression)
Configure a SpEL expression to determine the Kafka message key to store at runtime against
request Message as a root object of evaluation context.
|
<P> S |
partitionId(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.Integer> partitionIdFunction)
Configure a
Function that will be invoked at run time to determine the partition id under
which a message will be stored in the topic. |
S |
partitionId(java.lang.Integer partitionId)
Configure a partitionId of Kafka topic.
|
S |
partitionIdExpression(org.springframework.expression.Expression partitionIdExpression)
Configure an
Expression to determine the topic partitionId at runtime against
request Message as a root object of evaluation context. |
S |
partitionIdExpression(java.lang.String partitionIdExpression)
Configure a SpEL expression to determine the topic partitionId at runtime against
request Message as a root object of evaluation context.
|
S |
sendTimeout(long sendTimeout)
Specify a timeout in milliseconds how long
KafkaProducerMessageHandler
should wait wait for send operation results. |
S |
sync(boolean sync)
A
boolean indicating if the KafkaProducerMessageHandler
should wait for the send operation results or not. |
<P> S |
timestamp(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.Long> timestampFunction)
Configure a
Function that will be invoked at run time to determine the Kafka record timestamp
will be stored in the topic. |
S |
timestampExpression(org.springframework.expression.Expression timestampExpression)
Configure an
Expression to determine the timestamp at runtime against a
request Message as a root object of evaluation context. |
S |
timestampExpression(java.lang.String timestampExpression)
Configure a SpEL expression to determine the timestamp at runtime against a
request Message as a root object of evaluation context.
|
<P> S |
topic(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.String> topicFunction)
Configure a
Function that will be invoked at run time to determine the topic to
which a message will be sent. |
S |
topic(java.lang.String topic)
Configure the Kafka topic to send messages.
|
S |
topicExpression(org.springframework.expression.Expression topicExpression)
Configure an
Expression to determine the Kafka topic at runtime against
request Message as a root object of evaluation context. |
S |
topicExpression(java.lang.String topicExpression)
Configure a SpEL expression to determine the Kafka topic at runtime against
request Message as a root object of evaluation context.
|
public S topic(java.lang.String topic)
topic - the Kafka topic name.public S topicExpression(java.lang.String topicExpression)
topicExpression - the topic SpEL expression.public S topicExpression(org.springframework.expression.Expression topicExpression)
Expression to determine the Kafka topic at runtime against
request Message as a root object of evaluation context.topicExpression - the topic expression.public <P> S topic(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.String> topicFunction)
Function that will be invoked at run time to determine the topic to
which a message will be sent. Typically used with a Java 8 Lambda expression:
.<Foo>topic(m -> m.getPayload().getTopic())
P - the expected payload type.topicFunction - the topic function.KafkaProducerMessageHandlerSpec.FunctionExpressionpublic S messageKeyExpression(java.lang.String messageKeyExpression)
messageKeyExpression - the message key SpEL expression.public S messageKey(java.lang.String messageKey)
messageKey - the message key to use.public S messageKeyExpression(org.springframework.expression.Expression messageKeyExpression)
Expression to determine the Kafka message key to store at runtime against
request Message as a root object of evaluation context.messageKeyExpression - the message key expression.public <P> S messageKey(java.util.function.Function<org.springframework.messaging.Message<P>,?> messageKeyFunction)
Function that will be invoked at run time to determine the message key under
which a message will be stored in the topic. Typically used with a Java 8 Lambda expression:
.<Foo>messageKey(m -> m.getPayload().getKey())
P - the expected payload type.messageKeyFunction - the message key function.KafkaProducerMessageHandlerSpec.FunctionExpressionpublic S partitionId(java.lang.Integer partitionId)
partitionId - the partitionId to use.public S partitionIdExpression(java.lang.String partitionIdExpression)
partitionIdExpression - the partitionId expression to use.public <P> S partitionId(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.Integer> partitionIdFunction)
Function that will be invoked at run time to determine the partition id under
which a message will be stored in the topic. Typically used with a Java 8 Lambda expression:
.partitionId(m -> m.getHeaders().get("partitionId", Integer.class))
P - the expected payload type.partitionIdFunction - the partitionId function.public S partitionIdExpression(org.springframework.expression.Expression partitionIdExpression)
Expression to determine the topic partitionId at runtime against
request Message as a root object of evaluation context.partitionIdExpression - the partitionId expression to use.public S timestampExpression(java.lang.String timestampExpression)
timestampExpression - the timestamp expression to use.public <P> S timestamp(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.Long> timestampFunction)
Function that will be invoked at run time to determine the Kafka record timestamp
will be stored in the topic. Typically used with a Java 8 Lambda expression:
.timestamp(m -> m.getHeaders().get("mytimestamp_header", Long.class))
P - the expected payload type.timestampFunction - the partitionId function.public S timestampExpression(org.springframework.expression.Expression timestampExpression)
Expression to determine the timestamp at runtime against a
request Message as a root object of evaluation context.timestampExpression - the timestamp expression to use.public S sync(boolean sync)
boolean indicating if the KafkaProducerMessageHandler
should wait for the send operation results or not. Defaults to false.
In sync mode a downstream send operation exception will be re-thrown.sync - the send mode; async by default.public S sendTimeout(long sendTimeout)
KafkaProducerMessageHandler
should wait wait for send operation results. Defaults to 10 seconds.sendTimeout - the timeout to wait for result fo send operation.