October 2017
Intermediate to advanced
442 pages
12h 33m
English
The following snippet shows an event handler of the chef system, invoking functionality of a command service:
@Singleton
public class OrderEventHandler {
@Inject
MealPreparationService mealService;
public void handle(@Observes OrderPlaced event) {
mealService.prepareMeal(event.getOrderInfo());
}
}
The event handler consumes the event and will invoke the boundary of the subsequent meal preparation use case. The prepareMeal() method itself will result in zero or more events, in this case either MealPreparationStarted or OrderFailedInsufficientIngredients:
public class MealPreparationService {
@Inject
EventProducer eventProducer; @Inject IngredientStore ingredientStore; public void prepareMeal(OrderInfo orderInfo) { // use ingredientStore ...Read now
Unlock full access