Class KafkaInboundGateway<K,V,R>
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.MessagingGatewaySupport
org.springframework.integration.kafka.inbound.KafkaInboundGateway<K,V,R>
- Type Parameters:
K- the key type.V- the request value type.R- the reply value type.
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle,org.springframework.integration.context.ExpressionCapable,org.springframework.integration.context.OrderlyShutdownCapable,org.springframework.integration.core.Pausable,org.springframework.integration.IntegrationPattern,org.springframework.integration.support.context.NamedComponent,org.springframework.integration.support.management.IntegrationInboundManagement,org.springframework.integration.support.management.IntegrationManagement,org.springframework.integration.support.management.ManageableLifecycle,org.springframework.integration.support.management.ManageableSmartLifecycle,org.springframework.integration.support.management.TrackableComponent
public class KafkaInboundGateway<K,V,R>
extends org.springframework.integration.gateway.MessagingGatewaySupport
implements org.springframework.integration.core.Pausable, org.springframework.integration.context.OrderlyShutdownCapable
Inbound gateway.
- Since:
- 5.4
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
messagingTemplateFields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger -
Constructor Summary
Constructors Constructor Description KafkaInboundGateway(org.springframework.kafka.listener.AbstractMessageListenerContainer<K,V> messageListenerContainer, org.springframework.kafka.core.KafkaTemplate<K,R> kafkaTemplate)Construct an instance with the provided container. -
Method Summary
Modifier and Type Method Description intafterShutdown()intbeforeShutdown()protected voiddoStart()protected voiddoStop()java.lang.StringgetComponentType()protected org.springframework.core.AttributeAccessorgetErrorMessageAttributes(org.springframework.messaging.Message<?> message)booleanisPaused()protected voidonInit()voidpause()voidresume()voidsetBindSourceRecord(boolean bindSourceRecord)Set to true to bind the source consumer record in the header namedIntegrationMessageHeaderAccessor.SOURCE_DATA.voidsetMessageConverter(org.springframework.kafka.support.converter.RecordMessageConverter messageConverter)Set the message converter; must be aRecordMessageConverterorBatchMessageConverterdepending on mode.voidsetOnPartitionsAssignedSeekCallback(java.util.function.BiConsumer<java.util.Map<org.apache.kafka.common.TopicPartition,java.lang.Long>,org.springframework.kafka.listener.ConsumerSeekAware.ConsumerSeekCallback> onPartitionsAssignedCallback)Specify aBiConsumerfor seeks management duringConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekAware.ConsumerSeekCallback)call from theKafkaMessageListenerContainer.voidsetPayloadType(java.lang.Class<?> payloadType)When using a type-aware message converter (such asStringJsonMessageConverter, set the payload type the converter should create.voidsetRecoveryCallback(org.springframework.retry.RecoveryCallback<?> recoveryCallback)ARecoveryCallbackinstance for retry operation; if null, the exception will be thrown to the container after retries are exhausted (unless an error channel is configured).voidsetRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)Specify aRetryTemplateinstance to wrapKafkaInboundGateway.IntegrationRecordMessageListenerintoRetryingMessageListenerAdapter.Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
buildErrorMessage, buildSendTimer, destroy, getErrorChannel, getIntegrationPatternType, getManagedName, getManagedType, getOverrides, getReplyChannel, getRequestChannel, isLoggingEnabled, receive, receive, receiveMessage, receiveMessage, registerMetricsCaptor, registerReplyMessageCorrelatorIfNecessary, send, sendAndReceive, sendAndReceiveMessage, sendAndReceiveMessageReactive, sendTimer, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setErrorOnTimeout, setLoggingEnabled, setManagedName, setManagedType, setReplyChannel, setReplyChannelName, setReplyMapper, setReplyTimeout, setRequestChannel, setRequestChannelName, setRequestMapper, setRequestTimeout, setShouldTrackMethods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs
-
Constructor Details
-
KafkaInboundGateway
public KafkaInboundGateway(org.springframework.kafka.listener.AbstractMessageListenerContainer<K,V> messageListenerContainer, org.springframework.kafka.core.KafkaTemplate<K,R> kafkaTemplate)Construct an instance with the provided container.- Parameters:
messageListenerContainer- the container.kafkaTemplate- the kafka template.
-
-
Method Details
-
setMessageConverter
public void setMessageConverter(org.springframework.kafka.support.converter.RecordMessageConverter messageConverter)Set the message converter; must be aRecordMessageConverterorBatchMessageConverterdepending on mode.- Parameters:
messageConverter- the converter.
-
setPayloadType
public void setPayloadType(java.lang.Class<?> payloadType)When using a type-aware message converter (such asStringJsonMessageConverter, set the payload type the converter should create. Defaults toObject.- Parameters:
payloadType- the type.
-
setRetryTemplate
public void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)Specify aRetryTemplateinstance to wrapKafkaInboundGateway.IntegrationRecordMessageListenerintoRetryingMessageListenerAdapter.- Parameters:
retryTemplate- theRetryTemplateto use.
-
setRecoveryCallback
public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<?> recoveryCallback)ARecoveryCallbackinstance for retry operation; if null, the exception will be thrown to the container after retries are exhausted (unless an error channel is configured). Does not make sense ifsetRetryTemplate(RetryTemplate)isn't specified.- Parameters:
recoveryCallback- the recovery callback.
-
setOnPartitionsAssignedSeekCallback
public void setOnPartitionsAssignedSeekCallback(java.util.function.BiConsumer<java.util.Map<org.apache.kafka.common.TopicPartition,java.lang.Long>,org.springframework.kafka.listener.ConsumerSeekAware.ConsumerSeekCallback> onPartitionsAssignedCallback)Specify aBiConsumerfor seeks management duringConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekAware.ConsumerSeekCallback)call from theKafkaMessageListenerContainer. This is called from the internalMessagingMessageListenerAdapterimplementation.- Parameters:
onPartitionsAssignedCallback- theBiConsumerto use- Since:
- 3.0.4
- See Also:
ConsumerSeekAware.onPartitionsAssigned(java.util.Map<org.apache.kafka.common.TopicPartition, java.lang.Long>, org.springframework.kafka.listener.ConsumerSeekAware.ConsumerSeekCallback)
-
setBindSourceRecord
public void setBindSourceRecord(boolean bindSourceRecord)Set to true to bind the source consumer record in the header namedIntegrationMessageHeaderAccessor.SOURCE_DATA.- Parameters:
bindSourceRecord- true to bind.- Since:
- 3.1.4
-
onInit
protected void onInit()- Overrides:
onInitin classorg.springframework.integration.gateway.MessagingGatewaySupport
-
doStart
protected void doStart()- Overrides:
doStartin classorg.springframework.integration.gateway.MessagingGatewaySupport
-
doStop
protected void doStop()- Overrides:
doStopin classorg.springframework.integration.gateway.MessagingGatewaySupport
-
pause
public void pause()- Specified by:
pausein interfaceorg.springframework.integration.core.Pausable
-
resume
public void resume()- Specified by:
resumein interfaceorg.springframework.integration.core.Pausable
-
isPaused
public boolean isPaused()- Specified by:
isPausedin interfaceorg.springframework.integration.core.Pausable
-
getComponentType
public java.lang.String getComponentType()- Specified by:
getComponentTypein interfaceorg.springframework.integration.support.context.NamedComponent- Overrides:
getComponentTypein classorg.springframework.integration.gateway.MessagingGatewaySupport
-
beforeShutdown
public int beforeShutdown()- Specified by:
beforeShutdownin interfaceorg.springframework.integration.context.OrderlyShutdownCapable
-
afterShutdown
public int afterShutdown()- Specified by:
afterShutdownin interfaceorg.springframework.integration.context.OrderlyShutdownCapable
-
getErrorMessageAttributes
protected org.springframework.core.AttributeAccessor getErrorMessageAttributes(org.springframework.messaging.Message<?> message)- Overrides:
getErrorMessageAttributesin classorg.springframework.integration.gateway.MessagingGatewaySupport
-