Search in sources :

Example 1 with MultipleEventMessageListener

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;
}
Also used : PublishedEventWrapper(io.splitet.core.kafka.PublishedEventWrapper) StringDeserializer(org.apache.kafka.common.serialization.StringDeserializer) MultipleEventMessageListener(io.splitet.core.api.emon.service.MultipleEventMessageListener) ContainerProperties(org.springframework.kafka.listener.ContainerProperties) ConcurrentMessageListenerContainer(org.springframework.kafka.listener.ConcurrentMessageListenerContainer) DefaultKafkaConsumerFactory(org.springframework.kafka.core.DefaultKafkaConsumerFactory) Bean(org.springframework.context.annotation.Bean)

Example 2 with MultipleEventMessageListener

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;
}
Also used : StringDeserializer(org.apache.kafka.common.serialization.StringDeserializer) MultipleEventMessageListener(io.splitet.core.api.emon.service.MultipleEventMessageListener) ContainerProperties(org.springframework.kafka.listener.ContainerProperties) ConcurrentMessageListenerContainer(org.springframework.kafka.listener.ConcurrentMessageListenerContainer) Operation(io.splitet.core.pojos.Operation) DefaultKafkaConsumerFactory(org.springframework.kafka.core.DefaultKafkaConsumerFactory) Bean(org.springframework.context.annotation.Bean)

Aggregations

MultipleEventMessageListener (io.splitet.core.api.emon.service.MultipleEventMessageListener)2 StringDeserializer (org.apache.kafka.common.serialization.StringDeserializer)2 Bean (org.springframework.context.annotation.Bean)2 DefaultKafkaConsumerFactory (org.springframework.kafka.core.DefaultKafkaConsumerFactory)2 ConcurrentMessageListenerContainer (org.springframework.kafka.listener.ConcurrentMessageListenerContainer)2 ContainerProperties (org.springframework.kafka.listener.ContainerProperties)2 PublishedEventWrapper (io.splitet.core.kafka.PublishedEventWrapper)1 Operation (io.splitet.core.pojos.Operation)1