Class KafkaChannelDefinitionProcessor
java.lang.Object
org.flowable.eventregistry.spring.kafka.KafkaChannelDefinitionProcessor
- All Implemented Interfaces:
EventListener,org.flowable.eventregistry.api.ChannelModelProcessor,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.DisposableBean,org.springframework.context.ApplicationContextAware,org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
public class KafkaChannelDefinitionProcessor
extends Object
implements org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>, org.springframework.beans.factory.DisposableBean, org.flowable.eventregistry.api.ChannelModelProcessor
A
ChannelModelProcessor which is responsible for configuring Kafka Event registry integration.
This class is not meant to be extended.- Author:
- Filip Hrisafov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContextprotected org.springframework.beans.factory.BeanFactorystatic final Stringprotected org.springframework.kafka.config.KafkaListenerContainerFactory<?>protected Stringprotected booleanprotected static final intprotected org.springframework.util.StringValueResolverprotected org.springframework.kafka.config.KafkaListenerEndpointRegistryprotected org.springframework.beans.factory.config.BeanExpressionContextprotected org.springframework.kafka.core.KafkaAdminOperationsprotected final org.slf4j.Loggerprotected com.fasterxml.jackson.databind.ObjectMapperprotected org.springframework.beans.factory.config.BeanExpressionResolverprotected Map<String,Collection<String>> protected org.springframework.scheduling.TaskSchedulerprotected org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler -
Constructor Summary
ConstructorsConstructorDescriptionKafkaChannelDefinitionProcessor(com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanProcess(org.flowable.eventregistry.model.ChannelModel channelModel) booleancanProcessIfChannelModelAlreadyRegistered(org.flowable.eventregistry.model.ChannelModel channelModel) protected voidconfigurePartitionPausingFactory(org.springframework.kafka.listener.ContainerPartitionPausingBackOffManagerFactory factory) createEndpointConfigurations(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel, String tenantId, org.flowable.eventregistry.api.EventRegistry eventRegistry, org.springframework.kafka.config.KafkaListenerEndpoint mainEndpoint, org.springframework.kafka.config.KafkaListenerContainerFactory<?> containerFactory) protected org.springframework.kafka.config.KafkaListenerEndpointcreateKafkaListenerEndpoint(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel, String tenantId, org.flowable.eventregistry.api.EventRegistry eventRegistry) protected org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurercreateListenerContainerFactoryConfigurer(KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration retryConfiguration, org.springframework.util.backoff.BackOff backOff, org.springframework.kafka.retrytopic.DefaultDestinationTopicResolver topicResolver) protected org.springframework.kafka.listener.GenericMessageListener<org.apache.kafka.clients.consumer.ConsumerRecord<Object,Object>> createMessageListener(org.flowable.eventregistry.api.EventRegistry eventRegistry, org.flowable.eventregistry.model.InboundChannelModel inboundChannelModel) protected voidcreateNewTopics(Collection<String> topics, int numPartitions, short replicationFactor) protected org.springframework.retry.backoff.SleepingBackOffPolicy<?>createNonBlockingBackOffPolicy(org.flowable.eventregistry.model.KafkaInboundChannelModel.NonBlockingRetryBackOff backOff) protected org.springframework.kafka.retrytopic.RetryTopicConfigurationcreateRetryTopicConfiguration(KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration retryConfiguration) protected org.springframework.kafka.config.KafkaListenerContainerFactory<?>decorateFactory(org.springframework.kafka.retrytopic.DestinationTopic.Properties destinationTopicProperties, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer factoryConfigurer, org.springframework.kafka.retrytopic.RetryTopicConfiguration retryTopicConfiguration) voiddestroy()org.springframework.kafka.config.KafkaListenerContainerFactory<?>protected StringgetEndpointGroupId(org.flowable.eventregistry.model.KafkaInboundChannelModel channelDefinition, String id) protected StringgetEndpointId(org.flowable.eventregistry.model.ChannelModel channelModel, String tenantId) org.springframework.kafka.config.KafkaListenerEndpointRegistryorg.springframework.kafka.core.KafkaAdminOperationsprotected org.springframework.scheduling.TaskSchedulerorg.springframework.scheduling.TaskSchedulerprotected Consumer<Collection<String>>getTopicCreationFunction(KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration retryConfiguration) protected static Collection<org.springframework.kafka.support.TopicPartitionOffset>getTopicPartitions(org.springframework.kafka.retrytopic.DestinationTopic.Properties properties, org.springframework.kafka.support.Suffixer suffixer, org.springframework.kafka.support.TopicPartitionOffset[] topicPartitionOffsets) protected static org.springframework.kafka.support.TopicPartitionOffsetgetTPOForMainTopic(org.springframework.kafka.support.Suffixer suffixer, org.springframework.kafka.support.TopicPartitionOffset tpo) protected static org.springframework.kafka.support.TopicPartitionOffsetgetTPOForRetryTopics(org.springframework.kafka.retrytopic.DestinationTopic.Properties properties, org.springframework.kafka.support.Suffixer suffixer, org.springframework.kafka.support.TopicPartitionOffset tpo) voidonApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) parsePartitions(String partsString) Parse a list of partitions into aList.protected voidprocessAndRegisterEndpoints(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel, String tenantId, org.flowable.eventregistry.api.EventRegistry eventRegistry) protected voidprocessOutboundDefinition(org.flowable.eventregistry.model.KafkaOutboundChannelModel channelModel) voidregisterChannelModel(org.flowable.eventregistry.model.ChannelModel channelModel, String tenantId, org.flowable.eventregistry.api.EventRegistry eventRegistry, org.flowable.eventregistry.api.EventRepositoryService eventRepositoryService, boolean fallbackToDefaultTenant) protected voidregisterEndpoint(org.springframework.kafka.config.KafkaListenerEndpoint endpoint, org.springframework.kafka.config.KafkaListenerContainerFactory<?> factory) Register a newKafkaListenerEndpointalongside theKafkaListenerContainerFactoryto use to create the underlying container.protected Stringprotected org.springframework.kafka.config.KafkaListenerContainerFactory<?>resolveContainerFactory(org.springframework.kafka.config.KafkaListenerEndpoint endpoint, org.springframework.kafka.config.KafkaListenerContainerFactory<?> containerFactory) protected ObjectresolveExpression(String value) protected <T> TresolveExpression(String expression, Class<T> type) protected BooleanresolveExpressionAsBoolean(String value, String attribute) protected BooleanresolveExpressionAsBoolean(String value, String attribute, Boolean defaultValue) protected DoubleresolveExpressionAsDouble(String value, String attribute) protected IntegerresolveExpressionAsInteger(String value, String attribute) protected IntegerresolveExpressionAsInteger(String value, String attribute, Integer defaultValue) protected LongresolveExpressionAsLong(String value, String attribute) protected StringresolveExpressionAsString(String value, String attribute) protected KafkaPartitionProviderresolveKafkaPartitionProvider(org.flowable.eventregistry.model.KafkaOutboundChannelModel channelModel) protected voidresolvePartitionAsInteger(String topic, Object resolvedValue, List<org.springframework.kafka.support.TopicPartitionOffset> result) protected PatternresolvePattern(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel) protected PropertiesresolveProperties(List<org.flowable.eventregistry.model.KafkaInboundChannelModel.CustomProperty> consumerProperties) resolveRetryConfiguration(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel) protected Collection<org.springframework.kafka.support.TopicPartitionOffset>resolveTopicPartitions(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel) protected voidresolveTopics(Object resolvedValue, List<String> result, org.flowable.eventregistry.model.KafkaInboundChannelModel channelDefinition) protected Collection<String>resolveTopics(org.flowable.eventregistry.model.KafkaInboundChannelModel channelDefinition) voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) voidsetContainerFactory(org.springframework.kafka.config.KafkaListenerContainerFactory<?> containerFactory) voidsetContainerFactoryBeanName(String containerFactoryBeanName) voidsetEndpointRegistry(org.springframework.kafka.config.KafkaListenerEndpointRegistry endpointRegistry) voidsetKafkaAdminOperations(org.springframework.kafka.core.KafkaAdminOperations kafkaAdminOperations) voidsetKafkaOperations(org.springframework.kafka.core.KafkaOperations<Object, Object> kafkaOperations) voidsetRetryTopicTaskScheduler(org.springframework.scheduling.TaskScheduler retryTopicTaskScheduler) voidunregisterChannelModel(org.flowable.eventregistry.model.ChannelModel channelModel, String tenantId, org.flowable.eventregistry.api.EventRepositoryService eventRepositoryService) protected voidunregisterEndpoint(String endpointId, org.flowable.eventregistry.model.ChannelModel channelModel, String tenantId)
-
Field Details
-
CHANNEL_ID_PREFIX
- See Also:
-
DEFAULT_PARTITION_FOR_MANUAL_ASSIGNMENT
protected static final int DEFAULT_PARTITION_FOR_MANUAL_ASSIGNMENT- See Also:
-
logger
protected final org.slf4j.Logger logger -
kafkaOperations
-
kafkaAdminOperations
protected org.springframework.kafka.core.KafkaAdminOperations kafkaAdminOperations -
endpointRegistry
protected org.springframework.kafka.config.KafkaListenerEndpointRegistry endpointRegistry -
containerFactoryBeanName
-
containerFactory
protected org.springframework.kafka.config.KafkaListenerContainerFactory<?> containerFactory -
retryTopicTaskScheduler
protected org.springframework.scheduling.TaskScheduler retryTopicTaskScheduler -
retryTopicThreadPoolTaskScheduler
protected org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler retryTopicThreadPoolTaskScheduler -
beanFactory
protected org.springframework.beans.factory.BeanFactory beanFactory -
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
contextRefreshed
protected boolean contextRefreshed -
objectMapper
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper -
resolver
protected org.springframework.beans.factory.config.BeanExpressionResolver resolver -
embeddedValueResolver
protected org.springframework.util.StringValueResolver embeddedValueResolver -
expressionContext
protected org.springframework.beans.factory.config.BeanExpressionContext expressionContext -
retryEndpointsByMainEndpointId
-
-
Constructor Details
-
KafkaChannelDefinitionProcessor
public KafkaChannelDefinitionProcessor(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
canProcess
public boolean canProcess(org.flowable.eventregistry.model.ChannelModel channelModel) - Specified by:
canProcessin interfaceorg.flowable.eventregistry.api.ChannelModelProcessor
-
canProcessIfChannelModelAlreadyRegistered
public boolean canProcessIfChannelModelAlreadyRegistered(org.flowable.eventregistry.model.ChannelModel channelModel) - Specified by:
canProcessIfChannelModelAlreadyRegisteredin interfaceorg.flowable.eventregistry.api.ChannelModelProcessor
-
registerChannelModel
public void registerChannelModel(org.flowable.eventregistry.model.ChannelModel channelModel, String tenantId, org.flowable.eventregistry.api.EventRegistry eventRegistry, org.flowable.eventregistry.api.EventRepositoryService eventRepositoryService, boolean fallbackToDefaultTenant) - Specified by:
registerChannelModelin interfaceorg.flowable.eventregistry.api.ChannelModelProcessor
-
createKafkaListenerEndpoint
protected org.springframework.kafka.config.KafkaListenerEndpoint createKafkaListenerEndpoint(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel, String tenantId, org.flowable.eventregistry.api.EventRegistry eventRegistry) -
processAndRegisterEndpoints
protected void processAndRegisterEndpoints(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel, String tenantId, org.flowable.eventregistry.api.EventRegistry eventRegistry) -
createEndpointConfigurations
protected Collection<KafkaChannelDefinitionProcessor.Configuration> createEndpointConfigurations(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel, String tenantId, org.flowable.eventregistry.api.EventRegistry eventRegistry, org.springframework.kafka.config.KafkaListenerEndpoint mainEndpoint, org.springframework.kafka.config.KafkaListenerContainerFactory<?> containerFactory) -
getTopicPartitions
protected static Collection<org.springframework.kafka.support.TopicPartitionOffset> getTopicPartitions(org.springframework.kafka.retrytopic.DestinationTopic.Properties properties, org.springframework.kafka.support.Suffixer suffixer, org.springframework.kafka.support.TopicPartitionOffset[] topicPartitionOffsets) -
getTPOForRetryTopics
protected static org.springframework.kafka.support.TopicPartitionOffset getTPOForRetryTopics(org.springframework.kafka.retrytopic.DestinationTopic.Properties properties, org.springframework.kafka.support.Suffixer suffixer, org.springframework.kafka.support.TopicPartitionOffset tpo) -
getTPOForMainTopic
protected static org.springframework.kafka.support.TopicPartitionOffset getTPOForMainTopic(org.springframework.kafka.support.Suffixer suffixer, org.springframework.kafka.support.TopicPartitionOffset tpo) -
getTopicCreationFunction
protected Consumer<Collection<String>> getTopicCreationFunction(KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration retryConfiguration) -
createNewTopics
protected void createNewTopics(Collection<String> topics, int numPartitions, short replicationFactor) -
createListenerContainerFactoryConfigurer
protected org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer createListenerContainerFactoryConfigurer(KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration retryConfiguration, org.springframework.util.backoff.BackOff backOff, org.springframework.kafka.retrytopic.DefaultDestinationTopicResolver topicResolver) -
configurePartitionPausingFactory
protected void configurePartitionPausingFactory(org.springframework.kafka.listener.ContainerPartitionPausingBackOffManagerFactory factory) -
getOrCreateRetryTopicTaskScheduler
protected org.springframework.scheduling.TaskScheduler getOrCreateRetryTopicTaskScheduler() -
decorateFactory
protected org.springframework.kafka.config.KafkaListenerContainerFactory<?> decorateFactory(org.springframework.kafka.retrytopic.DestinationTopic.Properties destinationTopicProperties, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer factoryConfigurer, org.springframework.kafka.retrytopic.RetryTopicConfiguration retryTopicConfiguration) -
processOutboundDefinition
protected void processOutboundDefinition(org.flowable.eventregistry.model.KafkaOutboundChannelModel channelModel) -
resolveExpressionAsInteger
-
resolveExpressionAsInteger
-
resolveExpressionAsLong
-
resolveExpressionAsDouble
-
resolveExpressionAsBoolean
-
resolveExpressionAsBoolean
-
resolveExpressionAsString
-
resolveTopics
protected Collection<String> resolveTopics(org.flowable.eventregistry.model.KafkaInboundChannelModel channelDefinition) -
resolveTopics
-
resolvePattern
protected Pattern resolvePattern(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel) -
resolveTopicPartitions
protected Collection<org.springframework.kafka.support.TopicPartitionOffset> resolveTopicPartitions(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel) -
resolvePartitionAsInteger
-
parsePartitions
Parse a list of partitions into aList. Example: "0-5,10-15". This parsing is the same as it is done in the SpringKafkaListenerAnnotationBeanPostProcessor.- Parameters:
partsString- the comma-delimited list of partitions/ranges.- Returns:
- the stream of partition numbers, sorted and de-duplicated.
-
resolveKafkaPartitionProvider
protected KafkaPartitionProvider resolveKafkaPartitionProvider(org.flowable.eventregistry.model.KafkaOutboundChannelModel channelModel) -
resolveExpression
-
resolveExpression
-
createMessageListener
-
unregisterChannelModel
public void unregisterChannelModel(org.flowable.eventregistry.model.ChannelModel channelModel, String tenantId, org.flowable.eventregistry.api.EventRepositoryService eventRepositoryService) - Specified by:
unregisterChannelModelin interfaceorg.flowable.eventregistry.api.ChannelModelProcessor
-
unregisterEndpoint
-
registerEndpoint
protected void registerEndpoint(org.springframework.kafka.config.KafkaListenerEndpoint endpoint, org.springframework.kafka.config.KafkaListenerContainerFactory<?> factory) Register a newKafkaListenerEndpointalongside theKafkaListenerContainerFactoryto use to create the underlying container.The
factorymay benullif the default factory has to be used for that endpoint. -
resolveContainerFactory
protected org.springframework.kafka.config.KafkaListenerContainerFactory<?> resolveContainerFactory(org.springframework.kafka.config.KafkaListenerEndpoint endpoint, org.springframework.kafka.config.KafkaListenerContainerFactory<?> containerFactory) -
getEndpointId
-
getEndpointGroupId
-
resolve
-
resolveProperties
protected Properties resolveProperties(List<org.flowable.eventregistry.model.KafkaInboundChannelModel.CustomProperty> consumerProperties) -
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware- Throws:
org.springframework.beans.BeansException
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) - Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
-
destroy
- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
Exception
-
getKafkaOperations
-
setKafkaOperations
-
getKafkaAdminOperations
public org.springframework.kafka.core.KafkaAdminOperations getKafkaAdminOperations() -
setKafkaAdminOperations
public void setKafkaAdminOperations(org.springframework.kafka.core.KafkaAdminOperations kafkaAdminOperations) -
getEndpointRegistry
public org.springframework.kafka.config.KafkaListenerEndpointRegistry getEndpointRegistry() -
setEndpointRegistry
public void setEndpointRegistry(org.springframework.kafka.config.KafkaListenerEndpointRegistry endpointRegistry) -
getContainerFactoryBeanName
-
setContainerFactoryBeanName
-
getContainerFactory
public org.springframework.kafka.config.KafkaListenerContainerFactory<?> getContainerFactory() -
setContainerFactory
public void setContainerFactory(org.springframework.kafka.config.KafkaListenerContainerFactory<?> containerFactory) -
getRetryTopicTaskScheduler
public org.springframework.scheduling.TaskScheduler getRetryTopicTaskScheduler() -
setRetryTopicTaskScheduler
public void setRetryTopicTaskScheduler(org.springframework.scheduling.TaskScheduler retryTopicTaskScheduler) -
createRetryTopicConfiguration
protected org.springframework.kafka.retrytopic.RetryTopicConfiguration createRetryTopicConfiguration(KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration retryConfiguration) -
resolveRetryConfiguration
protected KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration resolveRetryConfiguration(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel) -
createNonBlockingBackOffPolicy
protected org.springframework.retry.backoff.SleepingBackOffPolicy<?> createNonBlockingBackOffPolicy(org.flowable.eventregistry.model.KafkaInboundChannelModel.NonBlockingRetryBackOff backOff)
-