Notification Microservice Prescription Microservice Schedule Microservice Medication Microservice User Microservice Inventory Microservice Until one day, the Architect Wizard™ arrived, and transformed it into microservices…. User Inventory Medication Schedule Notification Prescription Mediminder gateway Event bus
Notification Microservice Prescription Microservice Schedule Microservice Medication Microservice User Microservice Inventory Microservice Peace returned, until one day a microservice caught fire… User Inventory Medication Schedule Notification Prescription Mediminder gateway Event bus ❌
Notification Microservice Prescription Microservice Schedule Microservice Medication Microservice User Microservice Inventory Microservice And added extra infrastructure to prevent future problems User Inventory Medication Schedule Notification Prescription Mediminder gateway Event bus
Spring Data Events? @Entity // Extend from AbstractAggregateRoot public class Schedule extends AbstractAggregateRoot { @OneToMany private List completedEvents; public void addCompletedEvent(LocalDate eventDate) { this.completedEvents.add(CompletedEvent.of(this, eventDate)); // Call registerEvent() registerEvent(MedicationTakenEvent.of(this, eventDate)); } }
Spring Data Events? @Component @RequiredArgsConstructor public class MedicationTakenEventListener { private final InventoryFacade facade; @TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) public void subtractFromInventory(MedicationTakenEvent event) { facade.removeQuantity(event.userId(), event.medicationId(), event.quantity()); } }
Pro’s & Con’s ● Developed by Spring Data lead ● Favours conventions over configuration ● Easy integration with Spring Boot ● Only bootstraps module during tests ● Small community ● Does not replace microservices