Search in sources :

Example 1 with MultipleEventMessageListener

use of com.kloia.eventapis.api.emon.service.MultipleEventMessageListener in project eventapis by kloiasoft.

the class EventListenConfiguration method startOperations.

private void startOperations() {
    Map<String, Object> consumerProperties = eventApisConfiguration.getEventBus().buildConsumerProperties();
    DefaultKafkaConsumerFactory<String, Operation> operationConsumerFactory = new DefaultKafkaConsumerFactory<>(consumerProperties, new StringDeserializer(), new JsonDeserializer<>(Operation.class));
    ContainerProperties operationContainerProperties = new ContainerProperties(Operation.OPERATION_EVENTS);
    operationContainerProperties.setMessageListener(new MultipleEventMessageListener(eventMessageListeners));
    operationListenerContainer = new ConcurrentMessageListenerContainer<>(operationConsumerFactory, operationContainerProperties);
    operationListenerContainer.setBeanName("emon-operations");
    operationListenerContainer.start();
}
Also used : StringDeserializer(org.apache.kafka.common.serialization.StringDeserializer) MultipleEventMessageListener(com.kloia.eventapis.api.emon.service.MultipleEventMessageListener) ContainerProperties(org.springframework.kafka.listener.config.ContainerProperties) Operation(com.kloia.eventapis.pojos.Operation) DefaultKafkaConsumerFactory(org.springframework.kafka.core.DefaultKafkaConsumerFactory)

Example 2 with MultipleEventMessageListener

use of com.kloia.eventapis.api.emon.service.MultipleEventMessageListener 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

MultipleEventMessageListener (com.kloia.eventapis.api.emon.service.MultipleEventMessageListener)2 StringDeserializer (org.apache.kafka.common.serialization.StringDeserializer)2 DefaultKafkaConsumerFactory (org.springframework.kafka.core.DefaultKafkaConsumerFactory)2 ContainerProperties (org.springframework.kafka.listener.config.ContainerProperties)2 PublishedEventWrapper (com.kloia.eventapis.kafka.PublishedEventWrapper)1 Operation (com.kloia.eventapis.pojos.Operation)1