Search in sources :

Example 1 with StockReleasedEvent

use of com.kloia.sample.dto.event.StockReleasedEvent in project eventapis by kloiasoft.

the class WaitingStockReleaseEventHandler method execute.

@Override
@KafkaListener(topics = "WaitingStockReleaseEvent", containerFactory = "eventsKafkaListenerContainerFactory")
public EventKey execute(WaitingStockReleaseEvent dto) throws Exception {
    Stock stock = stockQuery.queryEntity(dto.getStockId());
    StockReservedEvent stockReservedEvent = stockQuery.queryEventData(dto.getStockId(), dto.getReservedStockVersion());
    return eventRepository.recordAndPublish(stock, new StockReleasedEvent(dto.getSender().getEntityId(), stockReservedEvent.getNumberOfItemsSold()), entityEvent -> new StockConcurrencyResolver());
}
Also used : StockReleasedEvent(com.kloia.sample.dto.event.StockReleasedEvent) StockReservedEvent(com.kloia.sample.dto.event.StockReservedEvent) Stock(com.kloia.sample.model.Stock) KafkaListener(org.springframework.kafka.annotation.KafkaListener)

Aggregations

StockReleasedEvent (com.kloia.sample.dto.event.StockReleasedEvent)1 StockReservedEvent (com.kloia.sample.dto.event.StockReservedEvent)1 Stock (com.kloia.sample.model.Stock)1 KafkaListener (org.springframework.kafka.annotation.KafkaListener)1