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.flowable.eventregistry.api.ChannelModelProcessor
ChannelModelProcessor which is responsible for configuring Kafka Event registry integration.
This class is not meant to be extended.| Modifier and Type | Class and Description |
|---|---|
protected static class |
KafkaChannelDefinitionProcessor.Configuration |
protected static class |
KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration |
protected static class |
KafkaChannelDefinitionProcessor.RetryTopicContainerFactoryDecorator |
| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.context.ApplicationContext |
applicationContext |
protected org.springframework.beans.factory.BeanFactory |
beanFactory |
static String |
CHANNEL_ID_PREFIX |
protected org.springframework.kafka.config.KafkaListenerContainerFactory<?> |
containerFactory |
protected String |
containerFactoryBeanName |
protected boolean |
contextRefreshed |
protected static int |
DEFAULT_PARTITION_FOR_MANUAL_ASSIGNMENT |
protected org.springframework.util.StringValueResolver |
embeddedValueResolver |
protected org.springframework.kafka.config.KafkaListenerEndpointRegistry |
endpointRegistry |
protected org.springframework.beans.factory.config.BeanExpressionContext |
expressionContext |
protected org.springframework.kafka.core.KafkaAdminOperations |
kafkaAdminOperations |
protected org.springframework.kafka.core.KafkaOperations<Object,Object> |
kafkaOperations |
protected org.slf4j.Logger |
logger |
protected com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
protected org.springframework.beans.factory.config.BeanExpressionResolver |
resolver |
protected Map<String,Collection<String>> |
retryEndpointsByMainEndpointId |
| Constructor and Description |
|---|
KafkaChannelDefinitionProcessor(com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canProcess(org.flowable.eventregistry.model.ChannelModel channelModel) |
boolean |
canProcessIfChannelModelAlreadyRegistered(org.flowable.eventregistry.model.ChannelModel channelModel) |
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) |
protected org.springframework.kafka.config.KafkaListenerEndpoint |
createKafkaListenerEndpoint(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel,
String tenantId,
org.flowable.eventregistry.api.EventRegistry eventRegistry) |
protected org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer |
createListenerContainerFactoryConfigurer(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 void |
createNewTopics(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.RetryTopicConfiguration |
createRetryTopicConfiguration(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) |
org.springframework.kafka.config.KafkaListenerContainerFactory<?> |
getContainerFactory() |
String |
getContainerFactoryBeanName() |
protected String |
getEndpointGroupId(org.flowable.eventregistry.model.KafkaInboundChannelModel channelDefinition,
String id) |
protected String |
getEndpointId(org.flowable.eventregistry.model.ChannelModel channelModel,
String tenantId) |
org.springframework.kafka.config.KafkaListenerEndpointRegistry |
getEndpointRegistry() |
org.springframework.kafka.core.KafkaAdminOperations |
getKafkaAdminOperations() |
org.springframework.kafka.core.KafkaOperations<Object,Object> |
getKafkaOperations() |
protected 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.TopicPartitionOffset |
getTPOForMainTopic(org.springframework.kafka.support.Suffixer suffixer,
org.springframework.kafka.support.TopicPartitionOffset tpo) |
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) |
void |
onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) |
protected Stream<Integer> |
parsePartitions(String partsString)
Parse a list of partitions into a
List. |
protected void |
processAndRegisterEndpoints(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel,
String tenantId,
org.flowable.eventregistry.api.EventRegistry eventRegistry) |
protected void |
processOutboundDefinition(org.flowable.eventregistry.model.KafkaOutboundChannelModel channelModel) |
void |
registerChannelModel(org.flowable.eventregistry.model.ChannelModel channelModel,
String tenantId,
org.flowable.eventregistry.api.EventRegistry eventRegistry,
org.flowable.eventregistry.api.EventRepositoryService eventRepositoryService,
boolean fallbackToDefaultTenant) |
protected void |
registerEndpoint(org.springframework.kafka.config.KafkaListenerEndpoint endpoint,
org.springframework.kafka.config.KafkaListenerContainerFactory<?> factory)
Register a new
KafkaListenerEndpoint alongside the
KafkaListenerContainerFactory to use to create the underlying container. |
protected String |
resolve(String value) |
protected org.springframework.kafka.config.KafkaListenerContainerFactory<?> |
resolveContainerFactory(org.springframework.kafka.config.KafkaListenerEndpoint endpoint,
org.springframework.kafka.config.KafkaListenerContainerFactory<?> containerFactory) |
protected Object |
resolveExpression(String value) |
protected <T> T |
resolveExpression(String expression,
Class<T> type) |
protected Boolean |
resolveExpressionAsBoolean(String value,
String attribute) |
protected Boolean |
resolveExpressionAsBoolean(String value,
String attribute,
Boolean defaultValue) |
protected Double |
resolveExpressionAsDouble(String value,
String attribute) |
protected Integer |
resolveExpressionAsInteger(String value,
String attribute) |
protected Integer |
resolveExpressionAsInteger(String value,
String attribute,
Integer defaultValue) |
protected Long |
resolveExpressionAsLong(String value,
String attribute) |
protected String |
resolveExpressionAsString(String value,
String attribute) |
protected KafkaPartitionProvider |
resolveKafkaPartitionProvider(org.flowable.eventregistry.model.KafkaOutboundChannelModel channelModel) |
protected void |
resolvePartitionAsInteger(String topic,
Object resolvedValue,
List<org.springframework.kafka.support.TopicPartitionOffset> result) |
protected Pattern |
resolvePattern(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel) |
protected Properties |
resolveProperties(List<org.flowable.eventregistry.model.KafkaInboundChannelModel.CustomProperty> consumerProperties) |
protected KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration |
resolveRetryConfiguration(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel) |
protected Collection<org.springframework.kafka.support.TopicPartitionOffset> |
resolveTopicPartitions(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel) |
protected Collection<String> |
resolveTopics(org.flowable.eventregistry.model.KafkaInboundChannelModel channelDefinition) |
protected void |
resolveTopics(Object resolvedValue,
List<String> result,
org.flowable.eventregistry.model.KafkaInboundChannelModel channelDefinition) |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) |
void |
setContainerFactory(org.springframework.kafka.config.KafkaListenerContainerFactory<?> containerFactory) |
void |
setContainerFactoryBeanName(String containerFactoryBeanName) |
void |
setEndpointRegistry(org.springframework.kafka.config.KafkaListenerEndpointRegistry endpointRegistry) |
void |
setKafkaAdminOperations(org.springframework.kafka.core.KafkaAdminOperations kafkaAdminOperations) |
void |
setKafkaOperations(org.springframework.kafka.core.KafkaOperations<Object,Object> kafkaOperations) |
void |
unregisterChannelModel(org.flowable.eventregistry.model.ChannelModel channelModel,
String tenantId,
org.flowable.eventregistry.api.EventRepositoryService eventRepositoryService) |
protected void |
unregisterEndpoint(String endpointId,
org.flowable.eventregistry.model.ChannelModel channelModel,
String tenantId) |
public static final String CHANNEL_ID_PREFIX
protected static final int DEFAULT_PARTITION_FOR_MANUAL_ASSIGNMENT
protected final org.slf4j.Logger logger
protected org.springframework.kafka.core.KafkaOperations<Object,Object> kafkaOperations
protected org.springframework.kafka.core.KafkaAdminOperations kafkaAdminOperations
protected org.springframework.kafka.config.KafkaListenerEndpointRegistry endpointRegistry
protected String containerFactoryBeanName
protected org.springframework.kafka.config.KafkaListenerContainerFactory<?> containerFactory
protected org.springframework.beans.factory.BeanFactory beanFactory
protected org.springframework.context.ApplicationContext applicationContext
protected boolean contextRefreshed
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
protected org.springframework.beans.factory.config.BeanExpressionResolver resolver
protected org.springframework.util.StringValueResolver embeddedValueResolver
protected org.springframework.beans.factory.config.BeanExpressionContext expressionContext
protected Map<String,Collection<String>> retryEndpointsByMainEndpointId
public KafkaChannelDefinitionProcessor(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
public boolean canProcess(org.flowable.eventregistry.model.ChannelModel channelModel)
canProcess in interface org.flowable.eventregistry.api.ChannelModelProcessorpublic boolean canProcessIfChannelModelAlreadyRegistered(org.flowable.eventregistry.model.ChannelModel channelModel)
canProcessIfChannelModelAlreadyRegistered in interface org.flowable.eventregistry.api.ChannelModelProcessorpublic void registerChannelModel(org.flowable.eventregistry.model.ChannelModel channelModel,
String tenantId,
org.flowable.eventregistry.api.EventRegistry eventRegistry,
org.flowable.eventregistry.api.EventRepositoryService eventRepositoryService,
boolean fallbackToDefaultTenant)
registerChannelModel in interface org.flowable.eventregistry.api.ChannelModelProcessorprotected org.springframework.kafka.config.KafkaListenerEndpoint createKafkaListenerEndpoint(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel,
String tenantId,
org.flowable.eventregistry.api.EventRegistry eventRegistry)
protected void processAndRegisterEndpoints(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel,
String tenantId,
org.flowable.eventregistry.api.EventRegistry eventRegistry)
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)
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.TopicPartitionOffset getTPOForRetryTopics(org.springframework.kafka.retrytopic.DestinationTopic.Properties properties,
org.springframework.kafka.support.Suffixer suffixer,
org.springframework.kafka.support.TopicPartitionOffset tpo)
protected static org.springframework.kafka.support.TopicPartitionOffset getTPOForMainTopic(org.springframework.kafka.support.Suffixer suffixer,
org.springframework.kafka.support.TopicPartitionOffset tpo)
protected Consumer<Collection<String>> getTopicCreationFunction(KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration retryConfiguration)
protected void createNewTopics(Collection<String> topics, int numPartitions, short replicationFactor)
protected org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer createListenerContainerFactoryConfigurer(KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration retryConfiguration, org.springframework.util.backoff.BackOff backOff, org.springframework.kafka.retrytopic.DefaultDestinationTopicResolver topicResolver)
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)
protected void processOutboundDefinition(org.flowable.eventregistry.model.KafkaOutboundChannelModel channelModel)
protected Integer resolveExpressionAsInteger(String value, String attribute)
protected Integer resolveExpressionAsInteger(String value, String attribute, Integer defaultValue)
protected Double resolveExpressionAsDouble(String value, String attribute)
protected Boolean resolveExpressionAsBoolean(String value, String attribute)
protected Boolean resolveExpressionAsBoolean(String value, String attribute, Boolean defaultValue)
protected String resolveExpressionAsString(String value, String attribute)
protected Collection<String> resolveTopics(org.flowable.eventregistry.model.KafkaInboundChannelModel channelDefinition)
protected void resolveTopics(Object resolvedValue, List<String> result, org.flowable.eventregistry.model.KafkaInboundChannelModel channelDefinition)
protected Pattern resolvePattern(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel)
protected Collection<org.springframework.kafka.support.TopicPartitionOffset> resolveTopicPartitions(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel)
protected void resolvePartitionAsInteger(String topic, Object resolvedValue, List<org.springframework.kafka.support.TopicPartitionOffset> result)
protected Stream<Integer> parsePartitions(String partsString)
List. Example: "0-5,10-15".
This parsing is the same as it is done in the Spring KafkaListenerAnnotationBeanPostProcessor.partsString - the comma-delimited list of partitions/ranges.protected KafkaPartitionProvider resolveKafkaPartitionProvider(org.flowable.eventregistry.model.KafkaOutboundChannelModel channelModel)
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)
public void unregisterChannelModel(org.flowable.eventregistry.model.ChannelModel channelModel,
String tenantId,
org.flowable.eventregistry.api.EventRepositoryService eventRepositoryService)
unregisterChannelModel in interface org.flowable.eventregistry.api.ChannelModelProcessorprotected void unregisterEndpoint(String endpointId, org.flowable.eventregistry.model.ChannelModel channelModel, String tenantId)
protected void registerEndpoint(org.springframework.kafka.config.KafkaListenerEndpoint endpoint,
org.springframework.kafka.config.KafkaListenerContainerFactory<?> factory)
KafkaListenerEndpoint alongside the
KafkaListenerContainerFactory to use to create the underlying container.
The factory may be null if the default factory has to be
used for that endpoint.
protected org.springframework.kafka.config.KafkaListenerContainerFactory<?> resolveContainerFactory(org.springframework.kafka.config.KafkaListenerEndpoint endpoint,
org.springframework.kafka.config.KafkaListenerContainerFactory<?> containerFactory)
protected String getEndpointId(org.flowable.eventregistry.model.ChannelModel channelModel, String tenantId)
protected String getEndpointGroupId(org.flowable.eventregistry.model.KafkaInboundChannelModel channelDefinition, String id)
protected Properties resolveProperties(List<org.flowable.eventregistry.model.KafkaInboundChannelModel.CustomProperty> consumerProperties)
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
throws org.springframework.beans.BeansException
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAwareorg.springframework.beans.BeansExceptionpublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionpublic void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>public org.springframework.kafka.core.KafkaOperations<Object,Object> getKafkaOperations()
public void setKafkaOperations(org.springframework.kafka.core.KafkaOperations<Object,Object> kafkaOperations)
public org.springframework.kafka.core.KafkaAdminOperations getKafkaAdminOperations()
public void setKafkaAdminOperations(org.springframework.kafka.core.KafkaAdminOperations kafkaAdminOperations)
public org.springframework.kafka.config.KafkaListenerEndpointRegistry getEndpointRegistry()
public void setEndpointRegistry(org.springframework.kafka.config.KafkaListenerEndpointRegistry endpointRegistry)
public String getContainerFactoryBeanName()
public void setContainerFactoryBeanName(String containerFactoryBeanName)
public org.springframework.kafka.config.KafkaListenerContainerFactory<?> getContainerFactory()
public void setContainerFactory(org.springframework.kafka.config.KafkaListenerContainerFactory<?> containerFactory)
protected org.springframework.kafka.retrytopic.RetryTopicConfiguration createRetryTopicConfiguration(KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration retryConfiguration)
protected KafkaChannelDefinitionProcessor.ResolvedRetryConfiguration resolveRetryConfiguration(org.flowable.eventregistry.model.KafkaInboundChannelModel channelModel)
protected org.springframework.retry.backoff.SleepingBackOffPolicy<?> createNonBlockingBackOffPolicy(org.flowable.eventregistry.model.KafkaInboundChannelModel.NonBlockingRetryBackOff backOff)
Copyright © 2022 Flowable. All rights reserved.