Search in sources :

Example 6 with ContainerProperties

use of org.springframework.kafka.listener.config.ContainerProperties in project eventapis by kloiasoft.

the class EventListenConfiguration method startEvents.

private void startEvents() {
    Map<String, Object> consumerProperties = eventApisConfiguration.getEventBus().buildConsumerProperties();
    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));
    messageListenerContainer = new ConcurrentMessageListenerContainer<>(consumerFactory, containerProperties);
    messageListenerContainer.setBeanName("emon-events");
    messageListenerContainer.start();
}
Also used : PublishedEventWrapper(com.kloia.eventapis.kafka.PublishedEventWrapper) StringDeserializer(org.apache.kafka.common.serialization.StringDeserializer) MultipleEventMessageListener(com.kloia.eventapis.api.emon.service.MultipleEventMessageListener) ContainerProperties(org.springframework.kafka.listener.config.ContainerProperties) DefaultKafkaConsumerFactory(org.springframework.kafka.core.DefaultKafkaConsumerFactory)

Aggregations

ContainerProperties (org.springframework.kafka.listener.config.ContainerProperties)6 DefaultKafkaConsumerFactory (org.springframework.kafka.core.DefaultKafkaConsumerFactory)3 MultipleEventMessageListener (com.kloia.eventapis.api.emon.service.MultipleEventMessageListener)2 StringDeserializer (org.apache.kafka.common.serialization.StringDeserializer)2 PublishedEventWrapper (com.kloia.eventapis.kafka.PublishedEventWrapper)1 Operation (com.kloia.eventapis.pojos.Operation)1 Test (org.junit.Test)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Listener (org.springframework.boot.autoconfigure.kafka.KafkaProperties.Listener)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1 Bean (org.springframework.context.annotation.Bean)1 ConcurrentKafkaListenerContainerFactory (org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory)1 ConsumerFactory (org.springframework.kafka.core.ConsumerFactory)1 ConcurrentMessageListenerContainer (org.springframework.kafka.listener.ConcurrentMessageListenerContainer)1