K
- the key type.V
- the value type.public class KafkaMessageDrivenChannelAdapter<K,V>
extends org.springframework.integration.endpoint.MessageProducerSupport
implements org.springframework.integration.context.OrderlyShutdownCapable
Modifier and Type | Class and Description |
---|---|
static class |
KafkaMessageDrivenChannelAdapter.ListenerMode
The listener mode for the container, record or batch.
|
Constructor and Description |
---|
KafkaMessageDrivenChannelAdapter(org.springframework.kafka.listener.AbstractMessageListenerContainer<K,V> messageListenerContainer)
Construct an instance with mode
KafkaMessageDrivenChannelAdapter.ListenerMode.record . |
KafkaMessageDrivenChannelAdapter(org.springframework.kafka.listener.AbstractMessageListenerContainer<K,V> messageListenerContainer,
KafkaMessageDrivenChannelAdapter.ListenerMode mode)
Construct an instance with the provided mode.
|
Modifier and Type | Method and Description |
---|---|
int |
afterShutdown() |
int |
beforeShutdown() |
protected void |
doStart() |
protected void |
doStop() |
java.lang.String |
getComponentType() |
protected void |
onInit() |
void |
setAckDiscarded(boolean ackDiscarded)
A
boolean flag to indicate if FilteringMessageListenerAdapter
should acknowledge discarded records or not. |
void |
setBatchMessageConverter(org.springframework.kafka.support.converter.BatchMessageConverter messageConverter)
Set the message converter to use with a batch-based consumer.
|
void |
setFilterInRetry(boolean filterInRetry)
The
boolean flag to specify the order how
RetryingMessageListenerAdapter and
FilteringMessageListenerAdapter are wrapped to each other,
if both of them are present. |
void |
setMessageConverter(org.springframework.kafka.support.converter.MessageConverter messageConverter)
Set the message converter; must be a
RecordMessageConverter or
BatchMessageConverter depending on mode. |
void |
setPayloadType(java.lang.Class<?> payloadType)
When using a type-aware message converter (such as
StringJsonMessageConverter ,
set the payload type the converter should create. |
void |
setRecordFilterStrategy(org.springframework.kafka.listener.adapter.RecordFilterStrategy<K,V> recordFilterStrategy)
Specify a
RecordFilterStrategy to wrap
KafkaMessageDrivenChannelAdapter.IntegrationRecordMessageListener into
FilteringMessageListenerAdapter . |
void |
setRecordMessageConverter(org.springframework.kafka.support.converter.RecordMessageConverter messageConverter)
Set the message converter to use with a record-based consumer.
|
void |
setRecoveryCallback(org.springframework.retry.RecoveryCallback<? extends java.lang.Object> recoveryCallback)
A
RecoveryCallback instance for retry operation;
if null, the exception will be thrown to the container after retries are exhausted. |
void |
setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)
Specify a
RetryTemplate instance to wrap
KafkaMessageDrivenChannelAdapter.IntegrationRecordMessageListener into
RetryingMessageListenerAdapter . |
afterSingletonsInstantiated, getErrorChannel, getMessagingTemplate, getOutputChannel, sendMessage, setErrorChannel, setErrorChannelName, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack
doStop, getPhase, isAutoStartup, isRunning, setAutoStartup, setPhase, setTaskScheduler, start, stop, stop
afterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, toString
public KafkaMessageDrivenChannelAdapter(org.springframework.kafka.listener.AbstractMessageListenerContainer<K,V> messageListenerContainer)
KafkaMessageDrivenChannelAdapter.ListenerMode.record
.messageListenerContainer
- the container.public KafkaMessageDrivenChannelAdapter(org.springframework.kafka.listener.AbstractMessageListenerContainer<K,V> messageListenerContainer, KafkaMessageDrivenChannelAdapter.ListenerMode mode)
messageListenerContainer
- the container.mode
- the mode.public void setMessageConverter(org.springframework.kafka.support.converter.MessageConverter messageConverter)
RecordMessageConverter
or
BatchMessageConverter
depending on mode.messageConverter
- the converter.public void setRecordMessageConverter(org.springframework.kafka.support.converter.RecordMessageConverter messageConverter)
messageConverter
- the converter.public void setBatchMessageConverter(org.springframework.kafka.support.converter.BatchMessageConverter messageConverter)
messageConverter
- the converter.public void setRecordFilterStrategy(org.springframework.kafka.listener.adapter.RecordFilterStrategy<K,V> recordFilterStrategy)
RecordFilterStrategy
to wrap
KafkaMessageDrivenChannelAdapter.IntegrationRecordMessageListener
into
FilteringMessageListenerAdapter
.recordFilterStrategy
- the RecordFilterStrategy
to use.public void setAckDiscarded(boolean ackDiscarded)
boolean
flag to indicate if FilteringMessageListenerAdapter
should acknowledge discarded records or not.
Does not make sense if setRecordFilterStrategy(RecordFilterStrategy)
isn't specified.ackDiscarded
- true to ack (commit offset for) discarded messages.public void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)
RetryTemplate
instance to wrap
KafkaMessageDrivenChannelAdapter.IntegrationRecordMessageListener
into
RetryingMessageListenerAdapter
.retryTemplate
- the RetryTemplate
to use.public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<? extends java.lang.Object> recoveryCallback)
RecoveryCallback
instance for retry operation;
if null, the exception will be thrown to the container after retries are exhausted.
Does not make sense if setRetryTemplate(RetryTemplate)
isn't specified.recoveryCallback
- the recovery callback.public void setFilterInRetry(boolean filterInRetry)
boolean
flag to specify the order how
RetryingMessageListenerAdapter
and
FilteringMessageListenerAdapter
are wrapped to each other,
if both of them are present.
Does not make sense if only one of RetryTemplate
or
RecordFilterStrategy
is present, or any.filterInRetry
- the order for RetryingMessageListenerAdapter
and
FilteringMessageListenerAdapter
wrapping. Defaults to false
.public void setPayloadType(java.lang.Class<?> payloadType)
StringJsonMessageConverter
,
set the payload type the converter should create. Defaults to Object
.payloadType
- the type.protected void onInit()
onInit
in class org.springframework.integration.endpoint.MessageProducerSupport
protected void doStart()
doStart
in class org.springframework.integration.endpoint.MessageProducerSupport
protected void doStop()
doStop
in class org.springframework.integration.endpoint.MessageProducerSupport
public java.lang.String getComponentType()
getComponentType
in interface org.springframework.integration.support.context.NamedComponent
getComponentType
in class org.springframework.integration.context.IntegrationObjectSupport
public int beforeShutdown()
beforeShutdown
in interface org.springframework.integration.context.OrderlyShutdownCapable
public int afterShutdown()
afterShutdown
in interface org.springframework.integration.context.OrderlyShutdownCapable