ventas-kafka-spark · sequence diagram

Scenario B · Out of stock

Variant: the purchase asks for 6 pairs of Levi's 502 jeans and only 5 are in stock. Inventory rejects the whole sale, no one else receives events, and main runs out its 60-second wait.

alt · out of stock loop · each line Simulacionmain() VentasServicecomprar() KafkaKRaft broker InventarioServicein-memory stock OrdenServicealReservar() PagoService16% VAT EntregaServicealPagar() MonitorFlujoCountDownLatch(1) Register the sale comprar(2 × PLY-AZUL-M, 6 × LEV-502-AZUL) send(sale.created, VentaCreada) ventaId esperarFin(60 s) Check stock sale.created · group inventario PLY-AZUL-M: 10 ≥ 2 → yes LEV-502-AZUL: 5 < 6 → no log.warn("Venta rechazada") · return stock unchanged: 10 and 5 inventory.reserved is never published No one else receives events Order, Payment and Delivery keep waiting latch still at 1 · 60 s go by esperarFin → false "Tiempo agotado esperando el flujo" · ctx.close() Result: no order, no payment, no delivery; the process exits with code 0 and analytics finds no payments
Solid arrows: calls or published messages. Dashed: replies or returns. Green: success. Red: rejections and errors. Dashed amber boxes: alternative branches; dashed blue boxes: optional steps or loops.

What to notice