use of com.kloia.sample.dto.event.OrderCancelledEvent in project eventapis by kloiasoft.
the class StockReleasedEventHandler method execute.
@KafkaListener(topics = "StockReleasedEvent", containerFactory = "eventsKafkaListenerContainerFactory")
public EventKey execute(StockReleasedEvent dto) throws EventStoreException, ConcurrentEventException {
Orders order = orderQuery.queryEntity(dto.getOrderId());
if (order.getState() == OrderState.RELEASING_STOCK) {
OrderCancelledEvent orderCancelledEvent = new OrderCancelledEvent();
log.info("Payment is processing : " + dto);
EventKey eventKey = eventRepository.recordAndPublish(order, orderCancelledEvent);
paymentClient.returnPaymentCommand(order.getPaymentId(), new ReturnPaymentCommandDto(order.getId()));
return eventKey;
} else
throw new EventStoreException("Order state is not valid for this Operation: " + dto);
}
Aggregations