use of io.splitet.core.api.emon.service.MultipleEventMessageListener in project eventapis by kloiasoft.
the class EventListenConfiguration method messageListenerContainer.
@Bean(name = "messageListenerContainer")
public ConcurrentMessageListenerContainer<String, PublishedEventWrapper> messageListenerContainer() {
Map<String, Object> consumerProperties = eventApisConfiguration.getEventBus().buildConsumerProperties();
consumerProperties.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
consumerProperties.put(ConsumerConfig.METADATA_MAX_AGE_CONFIG, 3000);
DefaultKafkaConsumerFactory<String, PublishedEventWrapper> consumerFactory = new DefaultKafkaConsumerFactory<>(consumerProperties, new StringDeserializer(), new JsonDeserializer<>(PublishedEventWrapper.class));
ContainerProperties containerProperties = new ContainerProperties(Pattern.compile(eventTopicRegexStr));
containerProperties.setMessageListener(new MultipleEventMessageListener(eventMessageListeners));
containerProperties.setAckMode(ContainerProperties.AckMode.BATCH);
ConcurrentMessageListenerContainer<String, PublishedEventWrapper> messageListenerContainer = new ConcurrentMessageListenerContainer<>(consumerFactory, containerProperties);
messageListenerContainer.setConcurrency(eventApisConfiguration.getEventBus().getConsumer().getEventConcurrency());
messageListenerContainer.setBeanName("emon-events");
return messageListenerContainer;
}
use of io.splitet.core.api.emon.service.MultipleEventMessageListener in project eventapis by kloiasoft.
the class EventListenConfiguration method operationListenerContainer.
@Bean(name = "operationListenerContainer")
public ConcurrentMessageListenerContainer<String, Operation> operationListenerContainer() {
Map<String, Object> consumerProperties = eventApisConfiguration.getEventBus().buildConsumerProperties();
consumerProperties.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
DefaultKafkaConsumerFactory<String, Operation> operationConsumerFactory = new DefaultKafkaConsumerFactory<>(consumerProperties, new StringDeserializer(), new JsonDeserializer<>(Operation.class));
ContainerProperties containerProperties = new ContainerProperties(Operation.OPERATION_EVENTS);
containerProperties.setMessageListener(new MultipleEventMessageListener(eventMessageListeners));
containerProperties.setAckMode(ContainerProperties.AckMode.BATCH);
ConcurrentMessageListenerContainer<String, Operation> operationListenerContainer = new ConcurrentMessageListenerContainer<>(operationConsumerFactory, containerProperties);
operationListenerContainer.setBeanName("emon-operations");
operationListenerContainer.setConcurrency(eventApisConfiguration.getEventBus().getConsumer().getOperationConcurrency());
return operationListenerContainer;
}
Aggregations