Why Event-Driven Communication

Request/Response vs Events

With Feign, order-service calls payment, inventory and notification services and waits for each. If one is down, the order fails. With events, order-service just announces "OrderPlaced #1001" to a message broker and returns. Every interested service reacts in its own time.

Synchronous (Feign)                        Event-driven (Kafka)
 order -> payment      (wait)               order --OrderPlaced--> [ topic: order-placed ]
 order -> inventory    (wait)                                         |       |        |
 order -> notification (wait)                                    payment  inventory  notification
 one service down = order fails             a consumer down = it catches up later
Synchronous REST/FeignAsynchronous events
CouplingCaller knows every calleeProducer does not know consumers
AvailabilityAll must be up at the same timeConsumers can be down for a while
Latency for the userSum of all callsOnly the producer's work
Adding a new consumerChange the callerJust subscribe to the topic
ConsistencyImmediateEventual (a few ms to seconds later)
Best forQueries that need an answer now ("get price")Facts that already happened ("order placed")

Events in ShopEase

EventProducerConsumers
OrderPlacedorder-servicepayment-service (charge), product-service (reserve stock), notification-service (SMS), analytics
PaymentCompleted / PaymentFailedpayment-serviceorder-service (update status), notification-service
ProductPriceChangedproduct-servicesearch index, cart (price alert)
UserRegistereduser-servicenotification-service (welcome email), coupons

Tip: Name events in the past tense (OrderPlaced, not PlaceOrder). An event is a fact; a command is a request that may be refused.