K - the key type.V - the value type.public class KafkaProducerMessageHandlerSpec<K,V> extends MessageHandlerSpec<KafkaProducerMessageHandlerSpec<K,V>,org.springframework.integration.kafka.outbound.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. |
| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.kafka.core.KafkaTemplate<K,V> |
kafkaTemplate |
id, logger, PARSER, target| Modifier and Type | Method and Description |
|---|---|
<P> KafkaProducerMessageHandlerSpec<K,V> |
messageKey(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. |
KafkaProducerMessageHandlerSpec<K,V> |
messageKey(java.lang.String messageKey)
Configure the message key to store message in Kafka topic.
|
KafkaProducerMessageHandlerSpec<K,V> |
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. |
KafkaProducerMessageHandlerSpec<K,V> |
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> KafkaProducerMessageHandlerSpec<K,V> |
partitionId(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. |
KafkaProducerMessageHandlerSpec<K,V> |
partitionId(java.lang.Integer partitionId)
Configure a partitionId of Kafka topic.
|
KafkaProducerMessageHandlerSpec<K,V> |
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. |
KafkaProducerMessageHandlerSpec<K,V> |
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.
|
KafkaProducerMessageHandlerSpec<K,V> |
sendTimeout(long sendTimeout)
Specify a timeout in milliseconds how long
KafkaProducerMessageHandler
should wait wait for send operation results. |
KafkaProducerMessageHandlerSpec<K,V> |
sync(boolean sync)
A
boolean indicating if the KafkaProducerMessageHandler
should wait for the send operation results or not. |
<P> KafkaProducerMessageHandlerSpec<K,V> |
topic(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. |
KafkaProducerMessageHandlerSpec<K,V> |
topic(java.lang.String topic)
Configure the Kafka topic to send messages.
|
KafkaProducerMessageHandlerSpec<K,V> |
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. |
KafkaProducerMessageHandlerSpec<K,V> |
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.
|
_this, doGet, get, getId, getObject, getObjectType, id, isSingletonpublic KafkaProducerMessageHandlerSpec<K,V> topic(java.lang.String topic)
topic - the Kafka topic name.public KafkaProducerMessageHandlerSpec<K,V> topicExpression(java.lang.String topicExpression)
topicExpression - the topic SpEL expression.public KafkaProducerMessageHandlerSpec<K,V> 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> KafkaProducerMessageHandlerSpec<K,V> topic(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 KafkaProducerMessageHandlerSpec<K,V> messageKeyExpression(java.lang.String messageKeyExpression)
messageKeyExpression - the message key SpEL expression.public KafkaProducerMessageHandlerSpec<K,V> messageKey(java.lang.String messageKey)
messageKey - the message key to use.public KafkaProducerMessageHandlerSpec<K,V> 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> KafkaProducerMessageHandlerSpec<K,V> messageKey(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 KafkaProducerMessageHandlerSpec<K,V> partitionId(java.lang.Integer partitionId)
partitionId - the partitionId to use.public KafkaProducerMessageHandlerSpec<K,V> partitionIdExpression(java.lang.String partitionIdExpression)
partitionIdExpression - the partitionId expression to use.public <P> KafkaProducerMessageHandlerSpec<K,V> partitionId(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 KafkaProducerMessageHandlerSpec<K,V> 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 KafkaProducerMessageHandlerSpec<K,V> 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 KafkaProducerMessageHandlerSpec<K,V> 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.