Search in sources :

Example 6 with Operation

use of com.kloia.eventapis.pojos.Operation in project eventapis by kloiasoft.

the class KafkaOperationRepository method successOperation.

@Override
public void successOperation(String eventId, SerializableConsumer<Event> action) {
    Operation operation = new Operation();
    operation.setSender(senderGroupId);
    operation.setAggregateId(eventId);
    operation.setTransactionState(TransactionState.TXN_SUCCEEDED);
    operation.setUserContext(userContext.getUserContext());
    operation.setContext(operationContext.getContext());
    operation.setOpDate(System.currentTimeMillis());
    log.debug("Publishing Operation:" + operation.toString());
    operationsKafka.send(new ProducerRecord<>(Operation.OPERATION_EVENTS, operationContext.getContext().getOpId(), operation));
}
Also used : Operation(com.kloia.eventapis.pojos.Operation)

Example 7 with Operation

use of com.kloia.eventapis.pojos.Operation in project eventapis by kloiasoft.

the class KafkaOperationRepositoryFactory method createKafkaOperationRepository.

public KafkaOperationRepository createKafkaOperationRepository(ObjectMapper objectMapper) {
    KafkaProducer<String, Operation> operationsKafka = new KafkaProducer<>(kafkaProperties.buildProducerProperties(), new StringSerializer(), new JsonSerializer<>(objectMapper));
    KafkaProducer<String, PublishedEventWrapper> eventsKafka = new KafkaProducer<>(kafkaProperties.buildProducerProperties(), new StringSerializer(), new JsonSerializer<>(objectMapper));
    return new KafkaOperationRepository(operationContext, userContext, operationsKafka, eventsKafka, kafkaProperties.getConsumer().getGroupId());
}
Also used : KafkaProducer(org.apache.kafka.clients.producer.KafkaProducer) Operation(com.kloia.eventapis.pojos.Operation) StringSerializer(org.apache.kafka.common.serialization.StringSerializer)

Aggregations

Operation (com.kloia.eventapis.pojos.Operation)7 StringDeserializer (org.apache.kafka.common.serialization.StringDeserializer)2 MultipleEventMessageListener (com.kloia.eventapis.api.emon.service.MultipleEventMessageListener)1 AggregateListener (com.kloia.eventapis.view.AggregateListener)1 KafkaConsumer (org.apache.kafka.clients.consumer.KafkaConsumer)1 KafkaProducer (org.apache.kafka.clients.producer.KafkaProducer)1 StringSerializer (org.apache.kafka.common.serialization.StringSerializer)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)1 Bean (org.springframework.context.annotation.Bean)1 KafkaListener (org.springframework.kafka.annotation.KafkaListener)1 DefaultKafkaConsumerFactory (org.springframework.kafka.core.DefaultKafkaConsumerFactory)1 KafkaMessageListenerContainer (org.springframework.kafka.listener.KafkaMessageListenerContainer)1 ContainerProperties (org.springframework.kafka.listener.config.ContainerProperties)1 RetryTemplate (org.springframework.retry.support.RetryTemplate)1 ThreadPoolTaskScheduler (org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler)1 Transactional (org.springframework.transaction.annotation.Transactional)1