Reactor
A reactor: a processor whose OnEvent functions act on committed events, such as sending a notification or calling another system. It replaces 9.x's @EventProcessor.
Each handler is compiled into its own subscription, named processor.function (or its Name). A handler takes the committed stream, or each of its events of a type, with the state after it, and optionally the me.ahoo.wow.api.subscribe.SubscriptionContext, whose invocationKey is the idempotency key for the outside call:
@Reactor
class OrderNotifier(private val mail: Mail) {
@OnEvent
fun onOrderShipped(event: StateTypedEvent<OrderState, OrderShipped>, context: SubscriptionContext) {
mail.send(event.state.customer, "Order shipped", key = context.invocationKey)
}
}Content copied to clipboard
A handler returns nothing, and may be suspend or return a Reactor Mono. A failure parks the aggregate in the failure ledger. The processor's dependencies are its constructor's parameters.
A processor is of exactly one kind: Projection, Reactor or Saga.