ventas-kafka-spark · sequence diagram

Scenario A · Successful sale

Said Olano buys 2 blue t-shirts and one pair of Levi's 502 jeans. Five services hand the sale over through five Kafka topics until delivery is scheduled. Total charged: $812.00.

loop · each line Simulacionmain() VentasServicecomprar() KafkaKRaft broker InventarioServicein-memory stock OrdenServicealReservar() PagoService16% VAT EntregaServicealPagar() MonitorFlujoCountDownLatch(1) Register the sale comprar("Said Olano", 2 lines) ventaId = VTA-xxxxxxxx send(sale.created, VentaCreada) ventaId esperarFin(60 s) · main blocks Reserve inventory (all or nothing) sale.created · group inventario available ≥ quantity? → yes PLY-AZUL-M 10 → 8 · LEV-502-AZUL 5 → 4 send(inventory.reserved) Create the order inventory.reserved · group orden ORD-xxxxxxxx · subtotal = 2×50 + 1×600 = 700.00 send(order.created, OrdenCreada) Charge with 16% VAT order.created · group pago VAT per line: 16.00 + 96.00 700.00 + 112.00 = 812.00 send(payment.processed, PagoProcesado) payment.processed stays stored for Spark Schedule the delivery payment.processed · group entrega ENT-xxxxxxxx · PROGRAMADA send(delivery.scheduled) Close the flow delivery.scheduled · group monitor-flujo fin.countDown() esperarFin → true "Flujo completado" · ctx.close() Result: sale paid for $812.00 and delivery scheduled; the container exits with code 0
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