I hereby claim:
- I am JohnChangUK on github.
- I am johnchang94 (https://keybase.io/johnchang94) on keybase.
- I have a public key whose fingerprint is 295E 4B4B 6709 C7AB 5A63 0A35 51CA 56A1 EFC4 DEC2
To claim this, I am signing this object:
public interface EventConsumer<T extends Event> { | |
void consumeEvent(T event); | |
} |
public interface EventHandler<T extends Event, R extends Event> { | |
R handleEvent(T event); | |
} |
@Component | |
public class OrderPurchaseEventHandler implements EventHandler<OrderPurchaseEvent, PaymentEvent> { | |
private final UserRepository userRepository; | |
@Autowired | |
public OrderPurchaseEventHandler(UserRepository userRepository) { | |
this.userRepository = userRepository; | |
} |
public void consumeEvent(TransactionEvent event) { | |
Mono.fromRunnable( | |
() -> orderPurchaseRepository.findById(event.getOrderId()) | |
.ifPresent(order -> { | |
setStatus(event, order); | |
orderPurchaseRepository.save(order); | |
})) | |
.subscribeOn(jdbcScheduler) | |
.subscribe(); | |
} |
public TransactionEvent handleEvent(PaymentEvent event) { | |
Mono.fromRunnable(() -> transactionRepository.save( | |
new Transaction() | |
.setOrderId(event.getOrderId()) | |
.setPrice(event.getPrice()))) | |
.subscribeOn(jdbcScheduler) | |
.subscribe(); | |
return new TransactionEvent() | |
.orderId(event.getOrderId()) |
@Component | |
public class OrderPurchaseProcessor { | |
private final Sinks.Many<OrderPurchaseEvent> sink; | |
@Autowired | |
public OrderPurchaseProcessor(Sinks.Many<OrderPurchaseEvent> sink) { | |
this.sink = sink; | |
} |
I hereby claim:
To claim this, I am signing this object: