K - the key type.V - the value type.public class KafkaProducerMessageHandler<K,V>
extends org.springframework.integration.handler.AbstractMessageProducingHandler
messagingTemplate| Constructor and Description |
|---|
KafkaProducerMessageHandler(org.springframework.kafka.core.KafkaTemplate<K,V> kafkaTemplate) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getComponentType() |
org.springframework.kafka.core.KafkaTemplate<?,?> |
getKafkaTemplate() |
protected org.springframework.messaging.MessageChannel |
getSendFailureChannel() |
protected void |
handleMessageInternal(org.springframework.messaging.Message<?> message) |
protected void |
onInit() |
void |
setErrorMessageStrategy(org.springframework.integration.support.ErrorMessageStrategy errorMessageStrategy)
Set the error message strategy implementation to use when sending error messages after
send failures.
|
void |
setHeaderMapper(org.springframework.kafka.support.KafkaHeaderMapper headerMapper)
Set the header mapper to use.
|
void |
setMessageKeyExpression(org.springframework.expression.Expression messageKeyExpression) |
void |
setPartitionIdExpression(org.springframework.expression.Expression partitionIdExpression) |
void |
setSendFailureChannel(org.springframework.messaging.MessageChannel sendFailureChannel)
Set the failure channel.
|
void |
setSendFailureChannelName(java.lang.String sendFailureChannelName)
Set the failure channel name.
|
void |
setSendTimeout(long sendTimeout)
Specify a timeout in milliseconds for how long this
KafkaProducerMessageHandler should wait wait for send operation
results. |
void |
setSendTimeoutExpression(org.springframework.expression.Expression sendTimeoutExpression)
Specify a SpEL expression to evaluate a timeout in milliseconds for how long this
KafkaProducerMessageHandler should wait wait for send operation
results. |
void |
setSync(boolean sync)
A
boolean indicating if the KafkaProducerMessageHandler
should wait for the send operation results or not. |
void |
setTimestampExpression(org.springframework.expression.Expression timestampExpression)
Specify a SpEL expression to evaluate a timestamp that will be added in the Kafka record.
|
void |
setTopicExpression(org.springframework.expression.Expression topicExpression) |
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, shouldCopyRequestHeaders, shouldSplitOutputconfigureMetrics, getActiveCount, getActiveCountLong, getDuration, getErrorCount, getErrorCountLong, getHandleCount, getHandleCountLong, getManagedName, getManagedType, getMaxDuration, getMeanDuration, getMinDuration, getOrder, getStandardDeviationDuration, handleMessage, isCountsEnabled, isLoggingEnabled, isStatsEnabled, reset, setCountsEnabled, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, setStatsEnabledafterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringpublic void setTopicExpression(org.springframework.expression.Expression topicExpression)
public void setMessageKeyExpression(org.springframework.expression.Expression messageKeyExpression)
public void setPartitionIdExpression(org.springframework.expression.Expression partitionIdExpression)
public void setTimestampExpression(org.springframework.expression.Expression timestampExpression)
Long type representing epoch time in milliseconds.timestampExpression - the Expression for timestamp to wait for result
fo send operation.public void setHeaderMapper(org.springframework.kafka.support.KafkaHeaderMapper headerMapper)
headerMapper - the mapper; can be null to disable header mapping.public org.springframework.kafka.core.KafkaTemplate<?,?> getKafkaTemplate()
public void setSync(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 void setSendTimeout(long sendTimeout)
KafkaProducerMessageHandler should wait wait for send operation
results. Defaults to 10 seconds. The timeout is applied only in sync mode.
Also applies when sending to the success or failure channels.setSendTimeout in class org.springframework.integration.handler.AbstractMessageProducingHandlersendTimeout - the timeout to wait for result fo send operation.public void setSendTimeoutExpression(org.springframework.expression.Expression sendTimeoutExpression)
KafkaProducerMessageHandler should wait wait for send operation
results. Defaults to 10 seconds. The timeout is applied only in sync mode.sendTimeoutExpression - the Expression for timeout to wait for result
fo send operation.public void setSendFailureChannel(org.springframework.messaging.MessageChannel sendFailureChannel)
ErrorMessage will be sent
to this channel with a payload of a KafkaSendFailureException with the
failed message and cause.sendFailureChannel - the failure channel.public void setSendFailureChannelName(java.lang.String sendFailureChannelName)
ErrorMessage will be
sent to this channel name with a payload of a KafkaSendFailureException
with the failed message and cause.sendFailureChannelName - the failure channel name.public void setErrorMessageStrategy(org.springframework.integration.support.ErrorMessageStrategy errorMessageStrategy)
errorMessageStrategy - the implementation.protected org.springframework.messaging.MessageChannel getSendFailureChannel()
protected void onInit()
throws java.lang.Exception
onInit in class org.springframework.integration.handler.AbstractMessageProducingHandlerjava.lang.Exceptionprotected void handleMessageInternal(org.springframework.messaging.Message<?> message)
throws java.lang.Exception
handleMessageInternal in class org.springframework.integration.handler.AbstractMessageHandlerjava.lang.Exceptionpublic java.lang.String getComponentType()
getComponentType in interface org.springframework.integration.support.context.NamedComponentgetComponentType in class org.springframework.integration.handler.AbstractMessageHandler