Class KafkaProducerMessageHandlerSpec<K,V,S extends KafkaProducerMessageHandlerSpec<K,V,S>>
java.lang.Object
org.springframework.beans.factory.config.AbstractFactoryBean<T>
org.springframework.integration.dsl.IntegrationComponentSpec<S,H>
org.springframework.integration.dsl.MessageHandlerSpec<S,KafkaProducerMessageHandler<K,V>>
org.springframework.integration.kafka.dsl.KafkaProducerMessageHandlerSpec<K,V,S>
- Type Parameters:
 K- the key type.V- the value type.S- theKafkaProducerMessageHandlerSpecextension type.
- All Implemented Interfaces:
 org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanClassLoaderAware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.FactoryBean<KafkaProducerMessageHandler<K,V>>,org.springframework.beans.factory.InitializingBean,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle
- Direct Known Subclasses:
 KafkaOutboundGatewaySpec,KafkaProducerMessageHandlerSpec.KafkaProducerMessageHandlerTemplateSpec
public class KafkaProducerMessageHandlerSpec<K,V,S extends KafkaProducerMessageHandlerSpec<K,V,S>> extends org.springframework.integration.dsl.MessageHandlerSpec<S,KafkaProducerMessageHandler<K,V>>
A 
MessageHandlerSpec implementation for the KafkaProducerMessageHandler.- Since:
 - 5.4
 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKafkaProducerMessageHandlerSpec.KafkaProducerMessageHandlerTemplateSpec<K,V>AKafkaTemplate-basedKafkaProducerMessageHandlerSpecextension. - 
Field Summary
 - 
Method Summary
Modifier and Type Method Description <P> Sflush(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.Boolean> flushFunction)Configure aFunctionthat will be invoked at runtime to determine whether or not to flush the producer after a send.SflushExpression(java.lang.String flushExpression)Configure a SpEL expression to determine whether or not to flush the producer after a send.SflushExpression(org.springframework.expression.Expression flushExpression)Configure anExpressionto determine whether or not to flush the producer after a send.SfuturesChannel(java.lang.String futuresChannel)Set the channel to which send futures are sent.SfuturesChannel(org.springframework.messaging.MessageChannel futuresChannel)Set the channel to which send futures are sent.SheaderMapper(org.springframework.kafka.support.KafkaHeaderMapper mapper)Specify a header mapper to map spring messaging headers to Kafka headers.SmessageKey(java.lang.String messageKey)Configure the message key to store message in Kafka topic.<P> SmessageKey(java.util.function.Function<org.springframework.messaging.Message<P>,?> messageKeyFunction)Configure aFunctionthat will be invoked at runtime to determine the message key under which a message will be stored in the topic.SmessageKeyExpression(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.SmessageKeyExpression(org.springframework.expression.Expression messageKeyExpression)Configure anExpressionto determine the Kafka message key to store at runtime against request Message as a root object of evaluation context.SpartitionId(java.lang.Integer partitionId)Configure a partitionId of Kafka topic.<P> SpartitionId(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.Integer> partitionIdFunction)Configure aFunctionthat will be invoked at runtime to determine the partition id under which a message will be stored in the topic.SpartitionIdExpression(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.SpartitionIdExpression(org.springframework.expression.Expression partitionIdExpression)Configure anExpressionto determine the topic partitionId at runtime against request Message as a root object of evaluation context.SsendFailureChannel(java.lang.String sendFailureChannel)Set the channel to which failed send results are sent.SsendFailureChannel(org.springframework.messaging.MessageChannel sendFailureChannel)Set the channel to which failed send results are sent.SsendSuccessChannel(java.lang.String sendSuccessChannel)Set the channel to which successful send results are sent.SsendSuccessChannel(org.springframework.messaging.MessageChannel sendSuccessChannel)Set the channel to which successful send results are sent.SsendTimeout(long sendTimeout)Specify a timeout in milliseconds how longKafkaProducerMessageHandlershould wait wait for send operation results.Ssync(boolean sync)Abooleanindicating if theKafkaProducerMessageHandlershould wait for the send operation results or not.<P> Stimestamp(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.Long> timestampFunction)Configure aFunctionthat will be invoked at runtime to determine the Kafka record timestamp will be stored in the topic.StimestampExpression(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.StimestampExpression(org.springframework.expression.Expression timestampExpression)Configure anExpressionto determine the timestamp at runtime against a request Message as a root object of evaluation context.Stopic(java.lang.String topic)Configure the Kafka topic to send messages.<P> Stopic(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.String> topicFunction)Configure aFunctionthat will be invoked at runtime to determine the topic to which a message will be sent.StopicExpression(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.StopicExpression(org.springframework.expression.Expression topicExpression)Configure anExpressionto determine the Kafka topic at runtime against request Message as a root object of evaluation context.Methods inherited from class org.springframework.integration.dsl.IntegrationComponentSpec
_this, createInstance, destroyInstance, doGet, get, getId, getObjectType, getPhase, id, isAutoStartup, isRunning, start, stop, stop 
- 
Method Details
- 
topic
Configure the Kafka topic to send messages.- Parameters:
 topic- the Kafka topic name.- Returns:
 - the spec.
 
 - 
topicExpression
Configure a SpEL expression to determine the Kafka topic at runtime against request Message as a root object of evaluation context.- Parameters:
 topicExpression- the topic SpEL expression.- Returns:
 - the spec.
 
 - 
topicExpression
Configure anExpressionto determine the Kafka topic at runtime against request Message as a root object of evaluation context.- Parameters:
 topicExpression- the topic expression.- Returns:
 - the spec.
 
 - 
topic
public <P> S topic(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.String> topicFunction)Configure aFunctionthat will be invoked at runtime 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())- Type Parameters:
 P- the expected payload type.- Parameters:
 topicFunction- the topic function.- Returns:
 - the current 
KafkaProducerMessageHandlerSpec. - See Also:
 FunctionExpression
 - 
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.- Parameters:
 messageKeyExpression- the message key SpEL expression.- Returns:
 - the spec.
 
 - 
messageKey
Configure the message key to store message in Kafka topic.- Parameters:
 messageKey- the message key to use.- Returns:
 - the spec.
 
 - 
messageKeyExpression
Configure anExpressionto determine the Kafka message key to store at runtime against request Message as a root object of evaluation context.- Parameters:
 messageKeyExpression- the message key expression.- Returns:
 - the spec.
 
 - 
messageKey
public <P> S messageKey(java.util.function.Function<org.springframework.messaging.Message<P>,?> messageKeyFunction)Configure aFunctionthat will be invoked at runtime 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())- Type Parameters:
 P- the expected payload type.- Parameters:
 messageKeyFunction- the message key function.- Returns:
 - the current 
KafkaProducerMessageHandlerSpec. - See Also:
 FunctionExpression
 - 
partitionId
Configure a partitionId of Kafka topic.- Parameters:
 partitionId- the partitionId to use.- Returns:
 - the spec.
 
 - 
partitionIdExpression
Configure a SpEL expression to determine the topic partitionId at runtime against request Message as a root object of evaluation context.- Parameters:
 partitionIdExpression- the partitionId expression to use.- Returns:
 - the spec.
 
 - 
partitionId
public <P> S partitionId(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.Integer> partitionIdFunction)Configure aFunctionthat will be invoked at runtime 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))- Type Parameters:
 P- the expected payload type.- Parameters:
 partitionIdFunction- the partitionId function.- Returns:
 - the spec.
 
 - 
partitionIdExpression
Configure anExpressionto determine the topic partitionId at runtime against request Message as a root object of evaluation context.- Parameters:
 partitionIdExpression- the partitionId expression to use.- Returns:
 - the spec.
 
 - 
timestampExpression
Configure a SpEL expression to determine the timestamp at runtime against a request Message as a root object of evaluation context.- Parameters:
 timestampExpression- the timestamp expression to use.- Returns:
 - the spec.
 
 - 
timestamp
public <P> S timestamp(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.Long> timestampFunction)Configure aFunctionthat will be invoked at runtime 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))- Type Parameters:
 P- the expected payload type.- Parameters:
 timestampFunction- the timestamp function.- Returns:
 - the spec.
 
 - 
timestampExpression
Configure anExpressionto determine the timestamp at runtime against a request Message as a root object of evaluation context.- Parameters:
 timestampExpression- the timestamp expression to use.- Returns:
 - the spec.
 
 - 
flushExpression
Configure a SpEL expression to determine whether or not to flush the producer after a send. By default the producer is flushed if a headerkafka_flushhas a valueBoolean.TRUE.- Parameters:
 flushExpression- the timestamp expression to use.- Returns:
 - the spec.
 
 - 
flush
public <P> S flush(java.util.function.Function<org.springframework.messaging.Message<P>,java.lang.Boolean> flushFunction)Configure aFunctionthat will be invoked at runtime to determine whether or not to flush the producer after a send. By default the producer is flushed if a headerkafka_flushhas a valueBoolean.TRUE. Typically used with a Java 8 Lambda expression:.flush(m -> m.getPayload().shouldFlush())- Type Parameters:
 P- the expected payload type.- Parameters:
 flushFunction- the flush function.- Returns:
 - the spec.
 
 - 
flushExpression
Configure anExpressionto determine whether or not to flush the producer after a send. By default the producer is flushed if a headerkafka_flushhas a valueBoolean.TRUE.- Parameters:
 flushExpression- the timestamp expression to use.- Returns:
 - the spec.
 
 - 
sync
Abooleanindicating if theKafkaProducerMessageHandlershould wait for the send operation results or not. Defaults tofalse. Insyncmode a downstream send operation exception will be re-thrown.- Parameters:
 sync- the send mode; async by default.- Returns:
 - the spec.
 
 - 
sendTimeout
Specify a timeout in milliseconds how longKafkaProducerMessageHandlershould wait wait for send operation results. Defaults to 10 seconds.- Parameters:
 sendTimeout- the timeout to wait for result fo send operation.- Returns:
 - the spec.
 
 - 
headerMapper
Specify a header mapper to map spring messaging headers to Kafka headers.- Parameters:
 mapper- the mapper.- Returns:
 - the spec.
 
 - 
sendSuccessChannel
Set the channel to which successful send results are sent.- Parameters:
 sendSuccessChannel- the channel.- Returns:
 - the spec.
 - Since:
 - 3.0.2
 
 - 
sendSuccessChannel
Set the channel to which successful send results are sent.- Parameters:
 sendSuccessChannel- the channel name.- Returns:
 - the spec.
 - Since:
 - 3.0.2
 
 - 
sendFailureChannel
Set the channel to which failed send results are sent.- Parameters:
 sendFailureChannel- the channel.- Returns:
 - the spec.
 - Since:
 - 3.0.2
 
 - 
sendFailureChannel
Set the channel to which failed send results are sent.- Parameters:
 sendFailureChannel- the channel name.- Returns:
 - the spec.
 - Since:
 - 3.0.2
 
 - 
futuresChannel
Set the channel to which send futures are sent.- Parameters:
 futuresChannel- the channel.- Returns:
 - the spec.
 - Since:
 - 5.4
 
 - 
futuresChannel
Set the channel to which send futures are sent.- Parameters:
 futuresChannel- the channel name.- Returns:
 - the spec.
 - Since:
 - 5.4
 
 
 -