├── .doc └── kafka.png ├── cloud-stream-kafka-playground ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ ├── application-sec12.yaml │ │ ├── application-sec02.yaml │ │ ├── application-sec03.yaml │ │ ├── application-sec11.yaml │ │ ├── application-sec04.yaml │ │ └── application-sec13.yaml │ │ └── java │ │ └── com │ │ └── vinsguru │ │ └── cloudstreamkafkaplayground │ │ ├── sec11 │ │ ├── dto │ │ │ ├── ContactMethod.java │ │ │ ├── Phone.java │ │ │ └── Email.java │ │ └── KafkaConsumer.java │ │ ├── sec05 │ │ └── dto │ │ │ ├── OrderType.java │ │ │ ├── DigitalDelivery.java │ │ │ ├── OrderEvent.java │ │ │ └── PhysicalDelivery.java │ │ ├── sec06 │ │ └── dto │ │ │ ├── OrderType.java │ │ │ ├── DigitalDelivery.java │ │ │ ├── OrderEvent.java │ │ │ └── PhysicalDelivery.java │ │ ├── sec08 │ │ └── dto │ │ │ ├── OrderType.java │ │ │ ├── DigitalDelivery.java │ │ │ ├── OrderEvent.java │ │ │ └── PhysicalDelivery.java │ │ ├── sec09 │ │ └── dto │ │ │ ├── OrderType.java │ │ │ ├── DigitalDelivery.java │ │ │ ├── OrderEvent.java │ │ │ └── PhysicalDelivery.java │ │ ├── common │ │ ├── Record.java │ │ └── MessageConverter.java │ │ ├── CloudStreamKafkaPlaygroundApplication.java │ │ ├── sec02 │ │ └── KafkaConsumer.java │ │ └── sec03 │ │ └── KafkaConsumer.java ├── .mvn │ └── wrapper │ │ └── maven-wrapper.jar └── .gitignore ├── saga-choreography ├── choreography-common │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── common │ │ │ ├── events │ │ │ ├── Saga.java │ │ │ ├── shipping │ │ │ │ ├── ShippingStatus.java │ │ │ │ └── ShippingEvent.java │ │ │ ├── order │ │ │ │ └── OrderStatus.java │ │ │ ├── DomainEvent.java │ │ │ ├── payment │ │ │ │ └── PaymentStatus.java │ │ │ ├── inventory │ │ │ │ └── InventoryStatus.java │ │ │ └── OrderSaga.java │ │ │ ├── util │ │ │ ├── Record.java │ │ │ └── MessageConverter.java │ │ │ ├── publisher │ │ │ └── EventPublisher.java │ │ │ ├── processor │ │ │ ├── EventProcessor.java │ │ │ ├── ShippingEventProcessor.java │ │ │ ├── OrderEventProcessor.java │ │ │ ├── PaymentEventProcessor.java │ │ │ └── InventoryEventProcessor.java │ │ │ ├── exception │ │ │ └── EventAlreadyProcessedException.java │ │ │ └── demo │ │ │ ├── MessageHandler.java │ │ │ ├── MessageHandlerImpl.java │ │ │ └── MessageHandlerDemo.java │ └── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── order-service │ ├── src │ │ ├── main │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── vinsguru │ │ │ │ └── order │ │ │ │ ├── common │ │ │ │ ├── service │ │ │ │ │ ├── OrderEventListener.java │ │ │ │ │ ├── OrderComponentFetcher.java │ │ │ │ │ ├── payment │ │ │ │ │ │ ├── PaymentComponentFetcher.java │ │ │ │ │ │ └── PaymentComponentStatusListener.java │ │ │ │ │ ├── inventory │ │ │ │ │ │ ├── InventoryComponentFetcher.java │ │ │ │ │ │ └── InventoryComponentStatusListener.java │ │ │ │ │ ├── OrderComponentStatusListener.java │ │ │ │ │ ├── shipping │ │ │ │ │ │ └── ShippingComponentStatusListener.java │ │ │ │ │ ├── OrderFulfillmentService.java │ │ │ │ │ └── OrderService.java │ │ │ │ └── dto │ │ │ │ │ ├── OrderDetails.java │ │ │ │ │ ├── OrderShipmentSchedule.java │ │ │ │ │ ├── OrderCreateRequest.java │ │ │ │ │ ├── OrderPaymentDto.java │ │ │ │ │ ├── OrderInventoryDto.java │ │ │ │ │ └── PurchaseOrderDto.java │ │ │ │ ├── OrderServiceApplication.java │ │ │ │ ├── application │ │ │ │ ├── repository │ │ │ │ │ ├── OrderPaymentRepository.java │ │ │ │ │ └── OrderInventoryRepository.java │ │ │ │ └── entity │ │ │ │ │ ├── OrderPayment.java │ │ │ │ │ ├── OrderInventory.java │ │ │ │ │ └── PurchaseOrder.java │ │ │ │ └── messaging │ │ │ │ ├── mapper │ │ │ │ └── ShippingEventMapper.java │ │ │ │ └── config │ │ │ │ └── OrderEventListenerConfig.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── order │ │ │ └── TestDataUtil.java │ └── .gitignore ├── shipping-service │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ ├── data.sql │ │ │ │ └── application.yaml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── vinsguru │ │ │ │ └── shipping │ │ │ │ ├── common │ │ │ │ ├── dto │ │ │ │ │ ├── ScheduleRequest.java │ │ │ │ │ └── ShipmentDto.java │ │ │ │ └── service │ │ │ │ │ └── ShippingService.java │ │ │ │ ├── ShippingServiceApplication.java │ │ │ │ └── application │ │ │ │ ├── repository │ │ │ │ └── ShipmentRepository.java │ │ │ │ └── entity │ │ │ │ └── Shipment.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── shipping │ │ │ └── AbstractIntegrationTest.java │ └── .gitignore ├── inventory-service │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── vinsguru │ │ │ │ │ └── inventory │ │ │ │ │ ├── common │ │ │ │ │ ├── exception │ │ │ │ │ │ └── OutOfStockException.java │ │ │ │ │ ├── dto │ │ │ │ │ │ ├── InventoryDeductRequest.java │ │ │ │ │ │ └── OrderInventoryDto.java │ │ │ │ │ └── service │ │ │ │ │ │ └── InventoryService.java │ │ │ │ │ ├── application │ │ │ │ │ ├── entity │ │ │ │ │ │ ├── Product.java │ │ │ │ │ │ └── OrderInventory.java │ │ │ │ │ └── repository │ │ │ │ │ │ ├── ProductRepository.java │ │ │ │ │ │ └── InventoryRepository.java │ │ │ │ │ └── InventoryServiceApplication.java │ │ │ └── resources │ │ │ │ ├── data.sql │ │ │ │ └── application.yaml │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── inventory │ │ │ └── AbstractIntegrationTest.java │ └── .gitignore ├── customer-payment │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── vinsguru │ │ │ │ │ └── payment │ │ │ │ │ ├── application │ │ │ │ │ ├── entity │ │ │ │ │ │ ├── Customer.java │ │ │ │ │ │ └── CustomerPayment.java │ │ │ │ │ └── repository │ │ │ │ │ │ ├── CustomerRepository.java │ │ │ │ │ │ └── PaymentRepository.java │ │ │ │ │ ├── common │ │ │ │ │ ├── dto │ │ │ │ │ │ ├── PaymentProcessRequest.java │ │ │ │ │ │ └── PaymentDto.java │ │ │ │ │ ├── exception │ │ │ │ │ │ ├── CustomerNotFoundException.java │ │ │ │ │ │ └── InsufficientBalanceException.java │ │ │ │ │ └── service │ │ │ │ │ │ └── PaymentService.java │ │ │ │ │ └── CustomerPaymentApplication.java │ │ │ └── resources │ │ │ │ ├── data.sql │ │ │ │ └── application.yaml │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── payment │ │ │ └── AbstractIntegrationTest.java │ └── .gitignore └── .gitignore ├── saga-choreography-outbox ├── choreography-common │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── common │ │ │ ├── events │ │ │ ├── Saga.java │ │ │ ├── shipping │ │ │ │ ├── ShippingStatus.java │ │ │ │ └── ShippingEvent.java │ │ │ ├── DomainEvent.java │ │ │ ├── order │ │ │ │ └── OrderStatus.java │ │ │ ├── payment │ │ │ │ └── PaymentStatus.java │ │ │ ├── inventory │ │ │ │ └── InventoryStatus.java │ │ │ └── OrderSaga.java │ │ │ ├── util │ │ │ ├── Record.java │ │ │ └── MessageConverter.java │ │ │ ├── listener │ │ │ ├── EventListener.java │ │ │ ├── ShippingEventListener.java │ │ │ ├── PaymentEventListener.java │ │ │ └── InventoryEventListener.java │ │ │ ├── outbox │ │ │ └── Outbox.java │ │ │ ├── processor │ │ │ ├── EventProcessor.java │ │ │ └── OrderEventProcessor.java │ │ │ ├── publisher │ │ │ └── EventPublisher.java │ │ │ ├── exception │ │ │ └── EventAlreadyProcessedException.java │ │ │ └── demo │ │ │ ├── MessageHandler.java │ │ │ ├── MessageHandlerImpl.java │ │ │ └── MessageHandlerDemo.java │ └── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── shipping-service │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── data.sql │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── vinsguru │ │ │ │ └── shipping │ │ │ │ ├── common │ │ │ │ ├── dto │ │ │ │ │ ├── ScheduleRequest.java │ │ │ │ │ └── ShipmentDto.java │ │ │ │ └── service │ │ │ │ │ └── ShippingService.java │ │ │ │ ├── ShippingServiceApplication.java │ │ │ │ └── application │ │ │ │ ├── repository │ │ │ │ └── ShipmentRepository.java │ │ │ │ └── entity │ │ │ │ └── Shipment.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── shipping │ │ │ └── AbstractIntegrationTest.java │ └── .gitignore ├── order-service │ ├── src │ │ ├── main │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── vinsguru │ │ │ │ └── order │ │ │ │ ├── common │ │ │ │ ├── service │ │ │ │ │ ├── OrderComponentFetcher.java │ │ │ │ │ ├── OrderFulfillmentService.java │ │ │ │ │ ├── payment │ │ │ │ │ │ ├── PaymentComponentFetcher.java │ │ │ │ │ │ └── PaymentComponentStatusListener.java │ │ │ │ │ ├── inventory │ │ │ │ │ │ ├── InventoryComponentFetcher.java │ │ │ │ │ │ └── InventoryComponentStatusListener.java │ │ │ │ │ ├── OrderComponentStatusListener.java │ │ │ │ │ ├── shipping │ │ │ │ │ │ └── ShippingComponentStatusListener.java │ │ │ │ │ ├── OrderEventListener.java │ │ │ │ │ └── OrderService.java │ │ │ │ └── dto │ │ │ │ │ ├── OrderDetails.java │ │ │ │ │ ├── OrderShipmentSchedule.java │ │ │ │ │ ├── OrderCreateRequest.java │ │ │ │ │ ├── OrderPaymentDto.java │ │ │ │ │ ├── OrderInventoryDto.java │ │ │ │ │ └── PurchaseOrderDto.java │ │ │ │ ├── OrderServiceApplication.java │ │ │ │ ├── messaging │ │ │ │ ├── publisher │ │ │ │ │ └── OrderEventOutboxService.java │ │ │ │ ├── repository │ │ │ │ │ └── OutboxRepository.java │ │ │ │ ├── entity │ │ │ │ │ └── OrderOutbox.java │ │ │ │ ├── mapper │ │ │ │ │ └── ShippingEventMapper.java │ │ │ │ └── listener │ │ │ │ │ └── ShippingEventListenerImpl.java │ │ │ │ └── application │ │ │ │ ├── repository │ │ │ │ ├── OrderPaymentRepository.java │ │ │ │ └── OrderInventoryRepository.java │ │ │ │ └── entity │ │ │ │ ├── OrderPayment.java │ │ │ │ ├── OrderInventory.java │ │ │ │ └── PurchaseOrder.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── order │ │ │ └── TestDataUtil.java │ └── .gitignore ├── customer-payment │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── vinsguru │ │ │ │ │ └── payment │ │ │ │ │ ├── application │ │ │ │ │ ├── entity │ │ │ │ │ │ ├── Customer.java │ │ │ │ │ │ └── CustomerPayment.java │ │ │ │ │ └── repository │ │ │ │ │ │ ├── CustomerRepository.java │ │ │ │ │ │ └── PaymentRepository.java │ │ │ │ │ ├── common │ │ │ │ │ ├── dto │ │ │ │ │ │ ├── PaymentProcessRequest.java │ │ │ │ │ │ └── PaymentDto.java │ │ │ │ │ ├── exception │ │ │ │ │ │ ├── CustomerNotFoundException.java │ │ │ │ │ │ └── InsufficientBalanceException.java │ │ │ │ │ └── service │ │ │ │ │ │ └── PaymentService.java │ │ │ │ │ └── CustomerPaymentApplication.java │ │ │ └── resources │ │ │ │ ├── data.sql │ │ │ │ └── application.yaml │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── payment │ │ │ └── AbstractIntegrationTest.java │ └── .gitignore ├── inventory-service │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── vinsguru │ │ │ │ │ └── inventory │ │ │ │ │ ├── common │ │ │ │ │ ├── exception │ │ │ │ │ │ └── OutOfStockException.java │ │ │ │ │ ├── dto │ │ │ │ │ │ ├── InventoryDeductRequest.java │ │ │ │ │ │ └── OrderInventoryDto.java │ │ │ │ │ └── service │ │ │ │ │ │ └── InventoryService.java │ │ │ │ │ ├── application │ │ │ │ │ ├── entity │ │ │ │ │ │ ├── Product.java │ │ │ │ │ │ └── OrderInventory.java │ │ │ │ │ └── repository │ │ │ │ │ │ ├── ProductRepository.java │ │ │ │ │ │ └── InventoryRepository.java │ │ │ │ │ └── InventoryServiceApplication.java │ │ │ └── resources │ │ │ │ └── data.sql │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── inventory │ │ │ └── AbstractIntegrationTest.java │ └── .gitignore └── .gitignore ├── saga-orchestrator ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── orchestrator-common │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── common │ │ │ ├── messages │ │ │ ├── Request.java │ │ │ ├── shipping │ │ │ │ ├── ShippingStatus.java │ │ │ │ ├── ShippingRequest.java │ │ │ │ └── ShippingResponse.java │ │ │ ├── Response.java │ │ │ ├── payment │ │ │ │ ├── PaymentStatus.java │ │ │ │ ├── PaymentRequest.java │ │ │ │ └── PaymentResponse.java │ │ │ └── inventory │ │ │ │ ├── InventoryStatus.java │ │ │ │ ├── InventoryRequest.java │ │ │ │ └── InventoryResponse.java │ │ │ ├── publisher │ │ │ └── EventPublisher.java │ │ │ ├── util │ │ │ ├── Record.java │ │ │ └── MessageConverter.java │ │ │ ├── orchestrator │ │ │ ├── WorkflowChain.java │ │ │ ├── RequestSender.java │ │ │ ├── RequestCompensator.java │ │ │ ├── WorkflowOrchestrator.java │ │ │ ├── ResponseProcessor.java │ │ │ └── WorkflowStep.java │ │ │ ├── exception │ │ │ └── EventAlreadyProcessedException.java │ │ │ ├── processor │ │ │ └── RequestProcessor.java │ │ │ └── demo │ │ │ ├── MessageHandler.java │ │ │ └── MessageHandlerImpl.java │ └── .gitignore ├── order-service │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── vinsguru │ │ │ │ │ └── order │ │ │ │ │ ├── common │ │ │ │ │ ├── enums │ │ │ │ │ │ ├── OrderStatus.java │ │ │ │ │ │ └── WorkflowAction.java │ │ │ │ │ ├── service │ │ │ │ │ │ ├── OrderEventListener.java │ │ │ │ │ │ ├── WorkflowActionTracker.java │ │ │ │ │ │ ├── WorkflowActionRetriever.java │ │ │ │ │ │ ├── OrderFulfillmentService.java │ │ │ │ │ │ └── OrderService.java │ │ │ │ │ └── dto │ │ │ │ │ │ ├── OrderDetails.java │ │ │ │ │ │ ├── OrderShipmentSchedule.java │ │ │ │ │ │ ├── OrderCreateRequest.java │ │ │ │ │ │ ├── OrderWorkflowActionDto.java │ │ │ │ │ │ └── PurchaseOrderDto.java │ │ │ │ │ ├── OrderServiceApplication.java │ │ │ │ │ ├── application │ │ │ │ │ ├── repository │ │ │ │ │ │ ├── PurchaseOrderRepository.java │ │ │ │ │ │ └── OrderWorkflowActionRepository.java │ │ │ │ │ └── entity │ │ │ │ │ │ ├── OrderWorkflowAction.java │ │ │ │ │ │ └── PurchaseOrder.java │ │ │ │ │ └── messaging │ │ │ │ │ ├── config │ │ │ │ │ └── OrderEventListenerConfig.java │ │ │ │ │ └── orchestrator │ │ │ │ │ ├── PaymentStep.java │ │ │ │ │ ├── ShippingStep.java │ │ │ │ │ └── InventoryStep.java │ │ │ └── resources │ │ │ │ └── data.sql │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── order │ │ │ └── TestDataUtil.java │ └── .gitignore ├── shipping-service │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── data.sql │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── vinsguru │ │ │ │ └── shipping │ │ │ │ ├── common │ │ │ │ ├── dto │ │ │ │ │ ├── ScheduleRequest.java │ │ │ │ │ └── ShipmentDto.java │ │ │ │ ├── service │ │ │ │ │ └── ShippingService.java │ │ │ │ └── exception │ │ │ │ │ └── ShipmentQuantityLimitExceededException.java │ │ │ │ ├── ShippingServiceApplication.java │ │ │ │ ├── application │ │ │ │ ├── repository │ │ │ │ │ └── ShipmentRepository.java │ │ │ │ └── entity │ │ │ │ │ └── Shipment.java │ │ │ │ └── messaging │ │ │ │ └── processor │ │ │ │ └── ShippingRequestProcessor.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── shipping │ │ │ ├── AbstractIntegrationTest.java │ │ │ └── TestDataUtil.java │ └── .gitignore ├── inventory-service │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── vinsguru │ │ │ │ │ └── inventory │ │ │ │ │ ├── common │ │ │ │ │ ├── exception │ │ │ │ │ │ └── OutOfStockException.java │ │ │ │ │ ├── dto │ │ │ │ │ │ ├── InventoryDeductRequest.java │ │ │ │ │ │ └── OrderInventoryDto.java │ │ │ │ │ └── service │ │ │ │ │ │ └── InventoryService.java │ │ │ │ │ ├── application │ │ │ │ │ ├── entity │ │ │ │ │ │ ├── Product.java │ │ │ │ │ │ └── OrderInventory.java │ │ │ │ │ └── repository │ │ │ │ │ │ ├── ProductRepository.java │ │ │ │ │ │ └── InventoryRepository.java │ │ │ │ │ ├── InventoryServiceApplication.java │ │ │ │ │ └── messaging │ │ │ │ │ └── processor │ │ │ │ │ └── InventoryRequestProcessor.java │ │ │ └── resources │ │ │ │ └── data.sql │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── inventory │ │ │ ├── AbstractIntegrationTest.java │ │ │ └── TestDataUtil.java │ └── .gitignore ├── customer-payment │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── vinsguru │ │ │ │ │ └── payment │ │ │ │ │ ├── application │ │ │ │ │ ├── entity │ │ │ │ │ │ ├── Customer.java │ │ │ │ │ │ └── CustomerPayment.java │ │ │ │ │ └── repository │ │ │ │ │ │ ├── CustomerRepository.java │ │ │ │ │ │ └── PaymentRepository.java │ │ │ │ │ ├── common │ │ │ │ │ ├── dto │ │ │ │ │ │ ├── PaymentProcessRequest.java │ │ │ │ │ │ └── PaymentDto.java │ │ │ │ │ ├── exception │ │ │ │ │ │ ├── CustomerNotFoundException.java │ │ │ │ │ │ └── InsufficientBalanceException.java │ │ │ │ │ └── service │ │ │ │ │ │ └── PaymentService.java │ │ │ │ │ ├── CustomerPaymentApplication.java │ │ │ │ │ └── messaging │ │ │ │ │ └── processor │ │ │ │ │ └── PaymentRequestProcessor.java │ │ │ └── resources │ │ │ │ └── data.sql │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── payment │ │ │ ├── AbstractIntegrationTest.java │ │ │ └── TestDataUtil.java │ └── .gitignore └── .gitignore ├── project-templates ├── saga-choreography │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── customer-payment │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── vinsguru │ │ │ │ └── Main.java │ │ └── .gitignore │ ├── inventory-service │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── vinsguru │ │ │ │ └── Main.java │ │ └── .gitignore │ ├── order-service │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── vinsguru │ │ │ │ └── Main.java │ │ └── .gitignore │ ├── shipping-service │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── vinsguru │ │ │ │ └── Main.java │ │ └── .gitignore │ ├── choreography-common │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── vinsguru │ │ │ │ └── Main.java │ │ └── .gitignore │ └── .gitignore └── saga-orchestrator │ ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── customer-payment │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── Main.java │ └── .gitignore │ ├── inventory-service │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── Main.java │ └── .gitignore │ ├── order-service │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── Main.java │ └── .gitignore │ ├── shipping-service │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── Main.java │ └── .gitignore │ ├── orchestrator-common │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── vinsguru │ │ │ └── Main.java │ └── .gitignore │ └── .gitignore └── kafka-setup ├── compose ├── docker-compose.yaml └── props │ └── server.properties └── image ├── Dockerfile └── runner.sh /.doc/kafka.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinsguru/reactive-event-driven-microservices/HEAD/.doc/kafka.png -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | sec=sec13 2 | spring.profiles.active=${sec} 3 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/events/Saga.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events; 2 | 3 | public interface Saga { 4 | } 5 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/events/Saga.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events; 2 | 3 | public interface Saga { 4 | } 5 | -------------------------------------------------------------------------------- /saga-choreography/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinsguru/reactive-event-driven-microservices/HEAD/saga-choreography/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /saga-orchestrator/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinsguru/reactive-event-driven-microservices/HEAD/saga-orchestrator/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /saga-choreography-outbox/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinsguru/reactive-event-driven-microservices/HEAD/saga-choreography-outbox/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinsguru/reactive-event-driven-microservices/HEAD/cloud-stream-kafka-playground/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /project-templates/saga-choreography/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinsguru/reactive-event-driven-microservices/HEAD/project-templates/saga-choreography/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinsguru/reactive-event-driven-microservices/HEAD/project-templates/saga-orchestrator/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec11/dto/ContactMethod.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec11.dto; 2 | 3 | public interface ContactMethod { 4 | void contact(); 5 | } 6 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/events/shipping/ShippingStatus.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events.shipping; 2 | 3 | public enum ShippingStatus { 4 | 5 | PENDING, 6 | SCHEDULED; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /project-templates/saga-choreography/customer-payment/src/main/java/com/vinsguru/Main.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /project-templates/saga-choreography/inventory-service/src/main/java/com/vinsguru/Main.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /project-templates/saga-choreography/order-service/src/main/java/com/vinsguru/Main.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /project-templates/saga-choreography/shipping-service/src/main/java/com/vinsguru/Main.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/customer-payment/src/main/java/com/vinsguru/Main.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/inventory-service/src/main/java/com/vinsguru/Main.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/order-service/src/main/java/com/vinsguru/Main.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/shipping-service/src/main/java/com/vinsguru/Main.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/events/shipping/ShippingStatus.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events.shipping; 2 | 3 | public enum ShippingStatus { 4 | 5 | PENDING, 6 | SCHEDULED; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/messages/Request.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.messages; 2 | 3 | import java.util.UUID; 4 | 5 | public interface Request { 6 | 7 | UUID orderId(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/messages/shipping/ShippingStatus.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.messages.shipping; 2 | 3 | public enum ShippingStatus { 4 | 5 | SCHEDULED, 6 | DECLINED; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec05/dto/OrderType.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec05.dto; 2 | 3 | public enum OrderType { 4 | 5 | DIGITAL, 6 | PHYSICAL; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec06/dto/OrderType.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec06.dto; 2 | 3 | public enum OrderType { 4 | 5 | DIGITAL, 6 | PHYSICAL; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec08/dto/OrderType.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec08.dto; 2 | 3 | public enum OrderType { 4 | 5 | DIGITAL, 6 | PHYSICAL; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec09/dto/OrderType.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec09.dto; 2 | 3 | public enum OrderType { 4 | 5 | DIGITAL, 6 | PHYSICAL; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /project-templates/saga-choreography/choreography-common/src/main/java/com/vinsguru/Main.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/Main.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/messages/Response.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.messages; 2 | 3 | import java.util.UUID; 4 | 5 | public interface Response { 6 | 7 | UUID orderId(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/common/enums/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.enums; 2 | 3 | public enum OrderStatus { 4 | 5 | PENDING, 6 | CANCELLED, 7 | COMPLETED; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/events/order/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events.order; 2 | 3 | public enum OrderStatus { 4 | 5 | PENDING, 6 | COMPLETED, 7 | CANCELLED; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/events/DomainEvent.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events; 2 | 3 | import java.time.Instant; 4 | 5 | public interface DomainEvent { 6 | 7 | Instant createdAt(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/events/DomainEvent.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events; 2 | 3 | import java.time.Instant; 4 | 5 | public interface DomainEvent { 6 | 7 | Instant createdAt(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/events/order/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events.order; 2 | 3 | public enum OrderStatus { 4 | 5 | PENDING, 6 | COMPLETED, 7 | CANCELLED; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/events/payment/PaymentStatus.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events.payment; 2 | 3 | public enum PaymentStatus { 4 | 5 | DEDUCTED, 6 | REFUNDED, 7 | DECLINED; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/events/payment/PaymentStatus.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events.payment; 2 | 3 | public enum PaymentStatus { 4 | 5 | DEDUCTED, 6 | REFUNDED, 7 | DECLINED; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/events/inventory/InventoryStatus.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events.inventory; 2 | 3 | public enum InventoryStatus { 4 | 5 | DEDUCTED, 6 | RESTORED, 7 | DECLINED; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/messages/payment/PaymentStatus.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.messages.payment; 2 | 3 | public enum PaymentStatus { 4 | 5 | PROCESSED, 6 | DECLINED, 7 | REFUNDED; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/messages/inventory/InventoryStatus.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.messages.inventory; 2 | 3 | public enum InventoryStatus { 4 | 5 | DEDUCTED, 6 | DECLINED, 7 | RESTORED; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec05/dto/DigitalDelivery.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec05.dto; 2 | 3 | public record DigitalDelivery(int productId, 4 | String email) { 5 | } 6 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec06/dto/DigitalDelivery.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec06.dto; 2 | 3 | public record DigitalDelivery(int productId, 4 | String email) { 5 | } 6 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec08/dto/DigitalDelivery.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec08.dto; 2 | 3 | public record DigitalDelivery(int productId, 4 | String email) { 5 | } 6 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec09/dto/DigitalDelivery.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec09.dto; 2 | 3 | public record DigitalDelivery(int productId, 4 | String email) { 5 | } 6 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/events/inventory/InventoryStatus.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events.inventory; 2 | 3 | public enum InventoryStatus { 4 | 5 | DEDUCTED, 6 | RESTORED, 7 | DECLINED; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/publisher/EventPublisher.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.publisher; 2 | 3 | import reactor.core.publisher.Flux; 4 | 5 | public interface EventPublisher { 6 | 7 | Flux publish(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 3 | -------------------------------------------------------------------------------- /saga-orchestrator/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 3 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/resources/application-sec12.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | function: 4 | definition: consumer 5 | stream: 6 | bindings: 7 | consumer-in-0: 8 | destination: input-topic1,input-topic2 9 | group: some-group 10 | -------------------------------------------------------------------------------- /saga-choreography-outbox/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 3 | -------------------------------------------------------------------------------- /project-templates/saga-choreography/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 3 | -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 3 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec05/dto/OrderEvent.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec05.dto; 2 | 3 | public record OrderEvent(int customerId, 4 | int productId, 5 | OrderType orderType) { 6 | } 7 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec06/dto/OrderEvent.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec06.dto; 2 | 3 | public record OrderEvent(int customerId, 4 | int productId, 5 | OrderType orderType) { 6 | } 7 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec08/dto/OrderEvent.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec08.dto; 2 | 3 | public record OrderEvent(int customerId, 4 | int productId, 5 | OrderType orderType) { 6 | } 7 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec09/dto/OrderEvent.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec09.dto; 2 | 3 | public record OrderEvent(int customerId, 4 | int productId, 5 | OrderType orderType) { 6 | } 7 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/util/Record.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.util; 2 | 3 | import reactor.kafka.receiver.ReceiverOffset; 4 | 5 | public record Record(String key, 6 | T message, 7 | ReceiverOffset acknowledgement) { 8 | } 9 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/util/Record.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.util; 2 | 3 | import reactor.kafka.receiver.ReceiverOffset; 4 | 5 | public record Record(String key, 6 | T message, 7 | ReceiverOffset acknowledgement) { 8 | } 9 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/orchestrator/WorkflowChain.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.orchestrator; 2 | 3 | public interface WorkflowChain { 4 | 5 | void setPreviousStep(RequestCompensator previousStep); 6 | 7 | void setNextStep(RequestSender nextStep); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/util/Record.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.util; 2 | 3 | import reactor.kafka.receiver.ReceiverOffset; 4 | 5 | public record Record(String key, 6 | T message, 7 | ReceiverOffset acknowledgement) { 8 | } 9 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/service/OrderEventListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import com.vinsguru.order.common.dto.PurchaseOrderDto; 4 | 5 | public interface OrderEventListener { 6 | 7 | void emitOrderCreated(PurchaseOrderDto dto); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/common/service/OrderEventListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import com.vinsguru.order.common.dto.PurchaseOrderDto; 4 | 5 | public interface OrderEventListener { 6 | 7 | void emitOrderCreated(PurchaseOrderDto dto); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography/shipping-service/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS shipment; 2 | 3 | CREATE TABLE shipment ( 4 | id uuid default random_uuid() primary key, 5 | order_id uuid, 6 | product_id int, 7 | customer_id int, 8 | quantity int, 9 | status VARCHAR(50), 10 | delivery_date TIMESTAMP 11 | ); 12 | -------------------------------------------------------------------------------- /saga-orchestrator/shipping-service/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS shipment; 2 | 3 | CREATE TABLE shipment ( 4 | id uuid default random_uuid() primary key, 5 | order_id uuid, 6 | product_id int, 7 | customer_id int, 8 | quantity int, 9 | status VARCHAR(50), 10 | delivery_date TIMESTAMP 11 | ); 12 | -------------------------------------------------------------------------------- /saga-choreography-outbox/shipping-service/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS shipment; 2 | 3 | CREATE TABLE shipment ( 4 | id uuid default random_uuid() primary key, 5 | order_id uuid, 6 | product_id int, 7 | customer_id int, 8 | quantity int, 9 | status VARCHAR(50), 10 | delivery_date TIMESTAMP 11 | ); 12 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/service/OrderComponentFetcher.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import reactor.core.publisher.Mono; 4 | 5 | import java.util.UUID; 6 | 7 | public interface OrderComponentFetcher { 8 | 9 | Mono getComponent(UUID orderId); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec11/dto/Phone.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec11.dto; 2 | 3 | public record Phone(int number) implements ContactMethod { 4 | @Override 5 | public void contact() { 6 | System.out.println("contacting via " + number); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/service/OrderComponentFetcher.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import reactor.core.publisher.Mono; 4 | 5 | import java.util.UUID; 6 | 7 | public interface OrderComponentFetcher { 8 | 9 | Mono getComponent(UUID orderId); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/publisher/EventPublisher.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.publisher; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import reactor.core.publisher.Flux; 5 | 6 | public interface EventPublisher { 7 | 8 | Flux publish(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/common/dto/OrderDetails.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.util.List; 6 | 7 | @Builder 8 | public record OrderDetails(PurchaseOrderDto order, 9 | List actions) { 10 | } 11 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/common/Record.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.common; 2 | 3 | import reactor.kafka.receiver.ReceiverOffset; 4 | 5 | public record Record(String key, 6 | T message, 7 | ReceiverOffset acknowledgement) { 8 | } 9 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/listener/EventListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.listener; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import reactor.core.publisher.Mono; 5 | 6 | public interface EventListener { 7 | 8 | Mono listen(T event); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/dto/OrderDetails.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | @Builder 6 | public record OrderDetails(PurchaseOrderDto order, 7 | OrderPaymentDto payment, 8 | OrderInventoryDto inventory) { 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/outbox/Outbox.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.outbox; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import lombok.Builder; 5 | 6 | @Builder 7 | public record Outbox(Long correlationId, 8 | T event) { 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/dto/OrderDetails.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | @Builder 6 | public record OrderDetails(PurchaseOrderDto order, 7 | OrderPaymentDto payment, 8 | OrderInventoryDto inventory) { 9 | } 10 | -------------------------------------------------------------------------------- /kafka-setup/compose/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "3.8" 2 | services: 3 | kafka: 4 | image: vinsdocker/kafka 5 | container_name: kafka 6 | ports: 7 | - "9092:9092" 8 | environment: 9 | KAFKA_CLUSTER_ID: OTMwNzFhYTY1ODNiNGE5OT 10 | volumes: 11 | - ./props/server.properties:/kafka/config/kraft/server.properties 12 | - ./data:/tmp/kafka-logs -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/events/OrderSaga.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events; 2 | 3 | import java.util.UUID; 4 | 5 | public interface OrderSaga extends Saga { 6 | 7 | /* 8 | Intentionally using UUID to keep things simple. Prefer record OrderId(UUID id){} 9 | */ 10 | UUID orderId(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec05/dto/PhysicalDelivery.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec05.dto; 2 | 3 | public record PhysicalDelivery(int productId, 4 | String street, 5 | String city, 6 | String country) { 7 | } 8 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec06/dto/PhysicalDelivery.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec06.dto; 2 | 3 | public record PhysicalDelivery(int productId, 4 | String street, 5 | String city, 6 | String country) { 7 | } 8 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec08/dto/PhysicalDelivery.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec08.dto; 2 | 3 | public record PhysicalDelivery(int productId, 4 | String street, 5 | String city, 6 | String country) { 7 | } 8 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec09/dto/PhysicalDelivery.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec09.dto; 2 | 3 | public record PhysicalDelivery(int productId, 4 | String street, 5 | String city, 6 | String country) { 7 | } 8 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/events/OrderSaga.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events; 2 | 3 | import java.util.UUID; 4 | 5 | public interface OrderSaga extends Saga { 6 | 7 | /* 8 | Intentionally using UUID to keep things simple. Prefer record OrderId(UUID id){} 9 | */ 10 | UUID orderId(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/processor/EventProcessor.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.processor; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import reactor.core.publisher.Mono; 5 | 6 | public interface EventProcessor { 7 | 8 | Mono process(T event); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/dto/OrderShipmentSchedule.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.time.Instant; 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record OrderShipmentSchedule(UUID orderId, 10 | Instant deliveryDate) { 11 | } 12 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/orchestrator/RequestSender.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.orchestrator; 2 | 3 | import com.vinsguru.common.messages.Request; 4 | import org.reactivestreams.Publisher; 5 | 6 | import java.util.UUID; 7 | 8 | public interface RequestSender { 9 | 10 | Publisher send(UUID id); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/common/dto/OrderShipmentSchedule.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.time.Instant; 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record OrderShipmentSchedule(UUID orderId, 10 | Instant deliveryDate) { 11 | } 12 | -------------------------------------------------------------------------------- /kafka-setup/image/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM eclipse-temurin:17-jre-focal 2 | 3 | ADD https://downloads.apache.org/kafka/3.4.0/kafka_2.13-3.4.0.tgz kafka.tgz 4 | 5 | RUN tar -xvzf kafka.tgz 6 | 7 | RUN rm kafka.tgz 8 | 9 | RUN mv /kafka_2.13-3.4.0 /kafka 10 | 11 | ENV PATH=${PATH}:/kafka/bin 12 | 13 | WORKDIR learning 14 | 15 | ADD runner.sh runner.sh 16 | 17 | CMD [ "sh", "runner.sh" ] -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/processor/EventProcessor.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.processor; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import reactor.core.publisher.Mono; 5 | 6 | public interface EventProcessor { 7 | 8 | Mono process(T event); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/dto/OrderShipmentSchedule.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.time.Instant; 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record OrderShipmentSchedule(UUID orderId, 10 | Instant deliveryDate) { 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography/inventory-service/src/main/java/com/vinsguru/inventory/common/exception/OutOfStockException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.common.exception; 2 | 3 | public class OutOfStockException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "Out of stock"; 6 | 7 | public OutOfStockException() { 8 | super(MESSAGE); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/service/payment/PaymentComponentFetcher.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service.payment; 2 | 3 | import com.vinsguru.order.common.dto.OrderPaymentDto; 4 | import com.vinsguru.order.common.service.OrderComponentFetcher; 5 | 6 | public interface PaymentComponentFetcher extends OrderComponentFetcher { 7 | } 8 | -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/main/java/com/vinsguru/inventory/common/exception/OutOfStockException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.common.exception; 2 | 3 | public class OutOfStockException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "Out of stock"; 6 | 7 | public OutOfStockException() { 8 | super(MESSAGE); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/orchestrator/RequestCompensator.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.orchestrator; 2 | 3 | import com.vinsguru.common.messages.Request; 4 | import org.reactivestreams.Publisher; 5 | 6 | import java.util.UUID; 7 | 8 | public interface RequestCompensator { 9 | 10 | Publisher compensate(UUID id); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/service/OrderFulfillmentService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import reactor.core.publisher.Mono; 4 | 5 | import java.util.UUID; 6 | 7 | public interface OrderFulfillmentService { 8 | 9 | Mono complete(UUID orderId); 10 | 11 | Mono cancel(UUID orderId); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/main/java/com/vinsguru/payment/application/entity/Customer.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.application.entity; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.annotation.Id; 5 | 6 | @Data 7 | public class Customer { 8 | 9 | @Id 10 | private Integer id; 11 | private String name; 12 | private Integer balance; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/main/java/com/vinsguru/payment/application/entity/Customer.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.application.entity; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.annotation.Id; 5 | 6 | @Data 7 | public class Customer { 8 | 9 | @Id 10 | private Integer id; 11 | private String name; 12 | private Integer balance; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/main/java/com/vinsguru/payment/application/entity/Customer.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.application.entity; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.annotation.Id; 5 | 6 | @Data 7 | public class Customer { 8 | 9 | @Id 10 | private Integer id; 11 | private String name; 12 | private Integer balance; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /saga-choreography-outbox/inventory-service/src/main/java/com/vinsguru/inventory/common/exception/OutOfStockException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.common.exception; 2 | 3 | public class OutOfStockException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "Out of stock"; 6 | 7 | public OutOfStockException() { 8 | super(MESSAGE); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/service/payment/PaymentComponentFetcher.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service.payment; 2 | 3 | import com.vinsguru.order.common.dto.OrderPaymentDto; 4 | import com.vinsguru.order.common.service.OrderComponentFetcher; 5 | 6 | public interface PaymentComponentFetcher extends OrderComponentFetcher { 7 | } 8 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/publisher/EventPublisher.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.publisher; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import com.vinsguru.common.outbox.Outbox; 5 | import reactor.core.publisher.Flux; 6 | 7 | public interface EventPublisher { 8 | 9 | Flux> publish(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/service/inventory/InventoryComponentFetcher.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service.inventory; 2 | 3 | import com.vinsguru.order.common.dto.OrderInventoryDto; 4 | import com.vinsguru.order.common.service.OrderComponentFetcher; 5 | 6 | public interface InventoryComponentFetcher extends OrderComponentFetcher { 7 | } 8 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/service/inventory/InventoryComponentFetcher.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service.inventory; 2 | 3 | import com.vinsguru.order.common.dto.OrderInventoryDto; 4 | import com.vinsguru.order.common.service.OrderComponentFetcher; 5 | 6 | public interface InventoryComponentFetcher extends OrderComponentFetcher { 7 | } 8 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/main/java/com/vinsguru/payment/common/dto/PaymentProcessRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.util.UUID; 6 | 7 | @Builder 8 | public record PaymentProcessRequest(Integer customerId, 9 | UUID orderId, 10 | Integer amount) { 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/main/java/com/vinsguru/payment/common/exception/CustomerNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.exception; 2 | 3 | public class CustomerNotFoundException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "Customer not found"; 6 | 7 | public CustomerNotFoundException() { 8 | super(MESSAGE); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/main/java/com/vinsguru/payment/common/dto/PaymentProcessRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.util.UUID; 6 | 7 | @Builder 8 | public record PaymentProcessRequest(Integer customerId, 9 | UUID orderId, 10 | Integer amount) { 11 | } 12 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/main/java/com/vinsguru/payment/common/exception/CustomerNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.exception; 2 | 3 | public class CustomerNotFoundException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "Customer not found"; 6 | 7 | public CustomerNotFoundException() { 8 | super(MESSAGE); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/main/java/com/vinsguru/payment/common/dto/PaymentProcessRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.util.UUID; 6 | 7 | @Builder 8 | public record PaymentProcessRequest(Integer customerId, 9 | UUID orderId, 10 | Integer amount) { 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography/inventory-service/src/main/java/com/vinsguru/inventory/application/entity/Product.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.application.entity; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.annotation.Id; 5 | 6 | @Data 7 | public class Product { 8 | 9 | @Id 10 | private Integer id; 11 | private String description; 12 | private Integer availableQuantity; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/service/OrderComponentStatusListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import reactor.core.publisher.Mono; 4 | 5 | public interface OrderComponentStatusListener { 6 | 7 | Mono onSuccess(T message); 8 | 9 | Mono onFailure(T message); 10 | 11 | Mono onRollback(T message); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/main/java/com/vinsguru/inventory/application/entity/Product.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.application.entity; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.annotation.Id; 5 | 6 | @Data 7 | public class Product { 8 | 9 | @Id 10 | private Integer id; 11 | private String description; 12 | private Integer availableQuantity; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/common/service/WorkflowActionTracker.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import com.vinsguru.order.common.enums.WorkflowAction; 4 | import reactor.core.publisher.Mono; 5 | 6 | import java.util.UUID; 7 | 8 | public interface WorkflowActionTracker { 9 | 10 | Mono track(UUID orderId, WorkflowAction action); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/main/java/com/vinsguru/payment/common/exception/CustomerNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.exception; 2 | 3 | public class CustomerNotFoundException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "Customer not found"; 6 | 7 | public CustomerNotFoundException() { 8 | super(MESSAGE); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography-outbox/inventory-service/src/main/java/com/vinsguru/inventory/application/entity/Product.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.application.entity; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.annotation.Id; 5 | 6 | @Data 7 | public class Product { 8 | 9 | @Id 10 | private Integer id; 11 | private String description; 12 | private Integer availableQuantity; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/service/OrderComponentStatusListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import reactor.core.publisher.Mono; 4 | 5 | public interface OrderComponentStatusListener { 6 | 7 | Mono onSuccess(T message); 8 | 9 | Mono onFailure(T message); 10 | 11 | Mono onRollback(T message); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/exception/EventAlreadyProcessedException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.exception; 2 | 3 | public class EventAlreadyProcessedException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "The event is already processed"; 6 | 7 | public EventAlreadyProcessedException() { 8 | super(MESSAGE); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /saga-choreography/inventory-service/src/main/java/com/vinsguru/inventory/common/dto/InventoryDeductRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.util.UUID; 6 | 7 | @Builder 8 | public record InventoryDeductRequest(UUID orderId, 9 | Integer productId, 10 | Integer quantity) { 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/dto/OrderCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | @Builder 6 | public record OrderCreateRequest(Integer customerId, 7 | Integer productId, 8 | Integer quantity, 9 | Integer unitPrice) { 10 | } 11 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/service/payment/PaymentComponentStatusListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service.payment; 2 | 3 | import com.vinsguru.order.common.dto.OrderPaymentDto; 4 | import com.vinsguru.order.common.service.OrderComponentStatusListener; 5 | 6 | public interface PaymentComponentStatusListener extends OrderComponentStatusListener { 7 | } 8 | -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/main/java/com/vinsguru/inventory/common/dto/InventoryDeductRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.util.UUID; 6 | 7 | @Builder 8 | public record InventoryDeductRequest(UUID orderId, 9 | Integer productId, 10 | Integer quantity) { 11 | } 12 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/exception/EventAlreadyProcessedException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.exception; 2 | 3 | public class EventAlreadyProcessedException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "The event is already processed"; 6 | 7 | public EventAlreadyProcessedException() { 8 | super(MESSAGE); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/orchestrator/WorkflowOrchestrator.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.orchestrator; 2 | 3 | import com.vinsguru.common.messages.Request; 4 | import com.vinsguru.common.messages.Response; 5 | import org.reactivestreams.Publisher; 6 | 7 | public interface WorkflowOrchestrator { 8 | 9 | Publisher orchestrate(Response response); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/processor/RequestProcessor.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.processor; 2 | 3 | import com.vinsguru.common.messages.Request; 4 | import com.vinsguru.common.messages.Response; 5 | import reactor.core.publisher.Mono; 6 | 7 | public interface RequestProcessor { 8 | 9 | Mono process(T request); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/common/dto/OrderCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | @Builder 6 | public record OrderCreateRequest(Integer customerId, 7 | Integer productId, 8 | Integer quantity, 9 | Integer unitPrice) { 10 | } 11 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/exception/EventAlreadyProcessedException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.exception; 2 | 3 | public class EventAlreadyProcessedException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "The event is already processed"; 6 | 7 | public EventAlreadyProcessedException() { 8 | super(MESSAGE); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /saga-choreography-outbox/inventory-service/src/main/java/com/vinsguru/inventory/common/dto/InventoryDeductRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.util.UUID; 6 | 7 | @Builder 8 | public record InventoryDeductRequest(UUID orderId, 9 | Integer productId, 10 | Integer quantity) { 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/dto/OrderCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | @Builder 6 | public record OrderCreateRequest(Integer customerId, 7 | Integer productId, 8 | Integer quantity, 9 | Integer unitPrice) { 10 | } 11 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/service/payment/PaymentComponentStatusListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service.payment; 2 | 3 | import com.vinsguru.order.common.dto.OrderPaymentDto; 4 | import com.vinsguru.order.common.service.OrderComponentStatusListener; 5 | 6 | public interface PaymentComponentStatusListener extends OrderComponentStatusListener { 7 | } 8 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/orchestrator/ResponseProcessor.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.orchestrator; 2 | 3 | import com.vinsguru.common.messages.Request; 4 | import com.vinsguru.common.messages.Response; 5 | import org.reactivestreams.Publisher; 6 | 7 | public interface ResponseProcessor { 8 | 9 | Publisher process(T response); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/common/service/WorkflowActionRetriever.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import com.vinsguru.order.common.dto.OrderWorkflowActionDto; 4 | import reactor.core.publisher.Flux; 5 | 6 | import java.util.UUID; 7 | 8 | public interface WorkflowActionRetriever { 9 | 10 | Flux retrieve(UUID orderId); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/service/inventory/InventoryComponentStatusListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service.inventory; 2 | 3 | import com.vinsguru.order.common.dto.OrderInventoryDto; 4 | import com.vinsguru.order.common.service.OrderComponentStatusListener; 5 | 6 | public interface InventoryComponentStatusListener extends OrderComponentStatusListener { 7 | } 8 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/service/shipping/ShippingComponentStatusListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service.shipping; 2 | 3 | import com.vinsguru.order.common.dto.OrderShipmentSchedule; 4 | import com.vinsguru.order.common.service.OrderComponentStatusListener; 5 | 6 | public interface ShippingComponentStatusListener extends OrderComponentStatusListener { 7 | } 8 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec11/dto/Email.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec11.dto; 2 | 3 | import com.vinsguru.cloudstreamkafkaplayground.sec11.dto.ContactMethod; 4 | 5 | public record Email(String email) implements ContactMethod { 6 | @Override 7 | public void contact() { 8 | System.out.println("contacting via " + email); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/service/inventory/InventoryComponentStatusListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service.inventory; 2 | 3 | import com.vinsguru.order.common.dto.OrderInventoryDto; 4 | import com.vinsguru.order.common.service.OrderComponentStatusListener; 5 | 6 | public interface InventoryComponentStatusListener extends OrderComponentStatusListener { 7 | } 8 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/service/shipping/ShippingComponentStatusListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service.shipping; 2 | 3 | import com.vinsguru.order.common.dto.OrderShipmentSchedule; 4 | import com.vinsguru.order.common.service.OrderComponentStatusListener; 5 | 6 | public interface ShippingComponentStatusListener extends OrderComponentStatusListener { 7 | } 8 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/main/java/com/vinsguru/payment/common/exception/InsufficientBalanceException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.exception; 2 | 3 | public class InsufficientBalanceException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "Customer does not have enough balance"; 6 | 7 | public InsufficientBalanceException() { 8 | super(MESSAGE); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography/shipping-service/src/main/java/com/vinsguru/shipping/common/dto/ScheduleRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.util.UUID; 6 | 7 | @Builder 8 | public record ScheduleRequest(UUID orderId, 9 | Integer productId, 10 | Integer customerId, 11 | Integer quantity) { 12 | } 13 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/main/java/com/vinsguru/payment/common/exception/InsufficientBalanceException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.exception; 2 | 3 | public class InsufficientBalanceException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "Customer does not have enough balance"; 6 | 7 | public InsufficientBalanceException() { 8 | super(MESSAGE); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-orchestrator/shipping-service/src/main/java/com/vinsguru/shipping/common/dto/ScheduleRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.util.UUID; 6 | 7 | @Builder 8 | public record ScheduleRequest(UUID orderId, 9 | Integer productId, 10 | Integer customerId, 11 | Integer quantity) { 12 | } 13 | -------------------------------------------------------------------------------- /saga-orchestrator/shipping-service/src/main/java/com/vinsguru/shipping/common/service/ShippingService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.common.service; 2 | 3 | import com.vinsguru.shipping.common.dto.ScheduleRequest; 4 | import com.vinsguru.shipping.common.dto.ShipmentDto; 5 | import reactor.core.publisher.Mono; 6 | 7 | public interface ShippingService { 8 | 9 | Mono schedule(ScheduleRequest request); 10 | 11 | } 12 | 13 | -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/main/java/com/vinsguru/payment/common/exception/InsufficientBalanceException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.exception; 2 | 3 | public class InsufficientBalanceException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "Customer does not have enough balance"; 6 | 7 | public InsufficientBalanceException() { 8 | super(MESSAGE); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /saga-choreography-outbox/shipping-service/src/main/java/com/vinsguru/shipping/common/dto/ScheduleRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.common.dto; 2 | 3 | import lombok.Builder; 4 | 5 | import java.util.UUID; 6 | 7 | @Builder 8 | public record ScheduleRequest(UUID orderId, 9 | Integer productId, 10 | Integer customerId, 11 | Integer quantity) { 12 | } 13 | -------------------------------------------------------------------------------- /saga-orchestrator/shipping-service/src/main/java/com/vinsguru/shipping/common/exception/ShipmentQuantityLimitExceededException.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.common.exception; 2 | 3 | public class ShipmentQuantityLimitExceededException extends RuntimeException { 4 | 5 | private static final String MESSAGE = "Shipment quantity exceeded the limit"; 6 | 7 | public ShipmentQuantityLimitExceededException() { 8 | super(MESSAGE); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/service/OrderFulfillmentService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import com.vinsguru.order.common.dto.PurchaseOrderDto; 4 | import reactor.core.publisher.Mono; 5 | 6 | import java.util.UUID; 7 | 8 | public interface OrderFulfillmentService { 9 | 10 | Mono complete(UUID orderId); 11 | 12 | Mono cancel(UUID orderId); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/demo/MessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.demo; 2 | 3 | import java.util.function.Function; 4 | 5 | public interface MessageHandler { 6 | 7 | MessageHandler onMessage(Class type, Function function); 8 | 9 | O handle(); 10 | 11 | static MessageHandler create(I input){ 12 | return new MessageHandlerImpl<>(input); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/demo/MessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.demo; 2 | 3 | import java.util.function.Function; 4 | 5 | public interface MessageHandler { 6 | 7 | MessageHandler onMessage(Class type, Function function); 8 | 9 | O handle(); 10 | 11 | static MessageHandler create(I input){ 12 | return new MessageHandlerImpl<>(input); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/demo/MessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.demo; 2 | 3 | import java.util.function.Function; 4 | 5 | public interface MessageHandler { 6 | 7 | MessageHandler onMessage(Class type, Function function); 8 | 9 | O handle(); 10 | 11 | static MessageHandler create(I input){ 12 | return new MessageHandlerImpl<>(input); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/OrderServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class OrderServiceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(OrderServiceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/OrderServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class OrderServiceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(OrderServiceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/OrderServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class OrderServiceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(OrderServiceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/main/java/com/vinsguru/payment/application/repository/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.application.repository; 2 | 3 | import com.vinsguru.payment.application.entity.Customer; 4 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface CustomerRepository extends ReactiveCrudRepository { 9 | } 10 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/main/java/com/vinsguru/payment/application/repository/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.application.repository; 2 | 3 | import com.vinsguru.payment.application.entity.Customer; 4 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface CustomerRepository extends ReactiveCrudRepository { 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography/inventory-service/src/main/java/com/vinsguru/inventory/application/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.application.repository; 2 | 3 | import com.vinsguru.inventory.application.entity.Product; 4 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface ProductRepository extends ReactiveCrudRepository { 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/dto/OrderPaymentDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import com.vinsguru.common.events.payment.PaymentStatus; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record OrderPaymentDto(UUID orderId, 10 | UUID paymentId, 11 | PaymentStatus status, 12 | String message) { 13 | } 14 | -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/main/java/com/vinsguru/inventory/application/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.application.repository; 2 | 3 | import com.vinsguru.inventory.application.entity.Product; 4 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface ProductRepository extends ReactiveCrudRepository { 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/main/java/com/vinsguru/payment/application/repository/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.application.repository; 2 | 3 | import com.vinsguru.payment.application.entity.Customer; 4 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface CustomerRepository extends ReactiveCrudRepository { 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography-outbox/inventory-service/src/main/java/com/vinsguru/inventory/application/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.application.repository; 2 | 3 | import com.vinsguru.inventory.application.entity.Product; 4 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface ProductRepository extends ReactiveCrudRepository { 9 | } 10 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/main/java/com/vinsguru/payment/CustomerPaymentApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class CustomerPaymentApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(CustomerPaymentApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography/shipping-service/src/main/java/com/vinsguru/shipping/ShippingServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ShippingServiceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ShippingServiceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/main/java/com/vinsguru/payment/CustomerPaymentApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class CustomerPaymentApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(CustomerPaymentApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-orchestrator/shipping-service/src/main/java/com/vinsguru/shipping/ShippingServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ShippingServiceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ShippingServiceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/main/java/com/vinsguru/payment/CustomerPaymentApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class CustomerPaymentApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(CustomerPaymentApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/dto/OrderPaymentDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import com.vinsguru.common.events.payment.PaymentStatus; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record OrderPaymentDto(UUID orderId, 10 | UUID paymentId, 11 | PaymentStatus status, 12 | String message) { 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography/inventory-service/src/main/java/com/vinsguru/inventory/InventoryServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class InventoryServiceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(InventoryServiceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/main/java/com/vinsguru/inventory/InventoryServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class InventoryServiceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(InventoryServiceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography-outbox/shipping-service/src/main/java/com/vinsguru/shipping/ShippingServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ShippingServiceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ShippingServiceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography-outbox/inventory-service/src/main/java/com/vinsguru/inventory/InventoryServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class InventoryServiceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(InventoryServiceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/service/OrderEventListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import com.vinsguru.order.common.dto.PurchaseOrderDto; 4 | import reactor.core.publisher.Mono; 5 | 6 | public interface OrderEventListener { 7 | 8 | Mono onOrderCreated(PurchaseOrderDto dto); 9 | 10 | Mono onOrderCancelled(PurchaseOrderDto dto); 11 | 12 | Mono onOrderCompleted(PurchaseOrderDto dto); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/messaging/publisher/OrderEventOutboxService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.messaging.publisher; 2 | 3 | import com.vinsguru.common.events.order.OrderEvent; 4 | import com.vinsguru.common.publisher.EventPublisher; 5 | import reactor.core.publisher.Mono; 6 | 7 | import java.util.List; 8 | 9 | public interface OrderEventOutboxService extends EventPublisher { 10 | 11 | Mono deleteEvents(List ids); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/dto/OrderInventoryDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import com.vinsguru.common.events.inventory.InventoryStatus; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record OrderInventoryDto(UUID orderId, 10 | UUID inventoryId, 11 | InventoryStatus status, 12 | String message) { 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/dto/OrderInventoryDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import com.vinsguru.common.events.inventory.InventoryStatus; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record OrderInventoryDto(UUID orderId, 10 | UUID inventoryId, 11 | InventoryStatus status, 12 | String message) { 13 | } 14 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/resources/application-sec02.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | function: 4 | definition: producer;consumer 5 | stream: 6 | bindings: 7 | consumer-in-0: 8 | destination: input-topic 9 | group: some-group 10 | producer-out-0: 11 | destination: input-topic 12 | # kafka: 13 | # bindings: 14 | # producer-out-0: 15 | # producer: 16 | # configuration: 17 | # "acks": "-1" -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/main/java/com/vinsguru/payment/common/dto/PaymentDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.dto; 2 | 3 | import com.vinsguru.common.events.payment.PaymentStatus; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record PaymentDto(UUID paymentId, 10 | UUID orderId, 11 | Integer customerId, 12 | Integer amount, 13 | PaymentStatus status) { 14 | } 15 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/main/java/com/vinsguru/payment/common/service/PaymentService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.service; 2 | 3 | import com.vinsguru.payment.common.dto.PaymentDto; 4 | import com.vinsguru.payment.common.dto.PaymentProcessRequest; 5 | import reactor.core.publisher.Mono; 6 | 7 | import java.util.UUID; 8 | 9 | public interface PaymentService { 10 | 11 | Mono process(PaymentProcessRequest request); 12 | 13 | Mono refund(UUID orderId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/main/java/com/vinsguru/payment/common/dto/PaymentDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.dto; 2 | 3 | import com.vinsguru.common.messages.payment.PaymentStatus; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record PaymentDto(UUID paymentId, 10 | UUID orderId, 11 | Integer customerId, 12 | Integer amount, 13 | PaymentStatus status) { 14 | } 15 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/main/java/com/vinsguru/payment/common/service/PaymentService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.service; 2 | 3 | import com.vinsguru.payment.common.dto.PaymentDto; 4 | import com.vinsguru.payment.common.dto.PaymentProcessRequest; 5 | import reactor.core.publisher.Mono; 6 | 7 | import java.util.UUID; 8 | 9 | public interface PaymentService { 10 | 11 | Mono process(PaymentProcessRequest request); 12 | 13 | Mono refund(UUID orderId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/main/java/com/vinsguru/payment/common/dto/PaymentDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.dto; 2 | 3 | import com.vinsguru.common.events.payment.PaymentStatus; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record PaymentDto(UUID paymentId, 10 | UUID orderId, 11 | Integer customerId, 12 | Integer amount, 13 | PaymentStatus status) { 14 | } 15 | -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/main/java/com/vinsguru/payment/common/service/PaymentService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.common.service; 2 | 3 | import com.vinsguru.payment.common.dto.PaymentDto; 4 | import com.vinsguru.payment.common.dto.PaymentProcessRequest; 5 | import reactor.core.publisher.Mono; 6 | 7 | import java.util.UUID; 8 | 9 | public interface PaymentService { 10 | 11 | Mono process(PaymentProcessRequest request); 12 | 13 | Mono refund(UUID orderId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/resources/application-sec03.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | function: 4 | definition: producer;consumer;processor 5 | stream: 6 | bindings: 7 | consumer-in-0: 8 | destination: output-topic 9 | group: consumer-group 10 | processor-in-0: 11 | destination: input-topic 12 | group: processor-group 13 | processor-out-0: 14 | destination: output-topic 15 | producer-out-0: 16 | destination: input-topic -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/common/dto/OrderWorkflowActionDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import com.vinsguru.order.common.enums.WorkflowAction; 4 | import lombok.Builder; 5 | 6 | import java.time.Instant; 7 | import java.util.UUID; 8 | 9 | @Builder 10 | public record OrderWorkflowActionDto(UUID id, 11 | UUID orderId, 12 | WorkflowAction action, 13 | Instant createdAt) { 14 | } 15 | -------------------------------------------------------------------------------- /saga-choreography/inventory-service/src/main/java/com/vinsguru/inventory/common/service/InventoryService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.common.service; 2 | 3 | import com.vinsguru.inventory.common.dto.InventoryDeductRequest; 4 | import com.vinsguru.inventory.common.dto.OrderInventoryDto; 5 | import reactor.core.publisher.Mono; 6 | 7 | import java.util.UUID; 8 | 9 | public interface InventoryService { 10 | 11 | Mono deduct(InventoryDeductRequest request); 12 | 13 | Mono restore(UUID orderId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/main/java/com/vinsguru/inventory/common/service/InventoryService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.common.service; 2 | 3 | import com.vinsguru.inventory.common.dto.InventoryDeductRequest; 4 | import com.vinsguru.inventory.common.dto.OrderInventoryDto; 5 | import reactor.core.publisher.Mono; 6 | 7 | import java.util.UUID; 8 | 9 | public interface InventoryService { 10 | 11 | Mono deduct(InventoryDeductRequest request); 12 | 13 | Mono restore(UUID orderId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /saga-choreography-outbox/inventory-service/src/main/java/com/vinsguru/inventory/common/service/InventoryService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.common.service; 2 | 3 | import com.vinsguru.inventory.common.dto.InventoryDeductRequest; 4 | import com.vinsguru.inventory.common.dto.OrderInventoryDto; 5 | import reactor.core.publisher.Mono; 6 | 7 | import java.util.UUID; 8 | 9 | public interface InventoryService { 10 | 11 | Mono deduct(InventoryDeductRequest request); 12 | 13 | Mono restore(UUID orderId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /saga-choreography/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /saga-choreography/shipping-service/src/main/java/com/vinsguru/shipping/common/service/ShippingService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.common.service; 2 | 3 | import com.vinsguru.shipping.common.dto.ScheduleRequest; 4 | import com.vinsguru.shipping.common.dto.ShipmentDto; 5 | import reactor.core.publisher.Mono; 6 | 7 | import java.util.UUID; 8 | 9 | public interface ShippingService { 10 | 11 | Mono addShipment(ScheduleRequest request); 12 | 13 | Mono cancel(UUID orderId); 14 | 15 | Mono schedule(UUID orderId); 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /saga-orchestrator/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /saga-choreography-outbox/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/messaging/repository/OutboxRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.messaging.repository; 2 | 3 | import com.vinsguru.order.messaging.entity.OrderOutbox; 4 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | import reactor.core.publisher.Flux; 7 | 8 | @Repository 9 | public interface OutboxRepository extends ReactiveCrudRepository { 10 | 11 | Flux findAllByOrderById(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saga-choreography/inventory-service/src/main/java/com/vinsguru/inventory/common/dto/OrderInventoryDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.common.dto; 2 | 3 | import com.vinsguru.common.events.inventory.InventoryStatus; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record OrderInventoryDto(UUID inventoryId, 10 | UUID orderId, 11 | Integer productId, 12 | Integer quantity, 13 | InventoryStatus status) { 14 | } 15 | -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/main/java/com/vinsguru/inventory/common/dto/OrderInventoryDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.common.dto; 2 | 3 | import com.vinsguru.common.messages.inventory.InventoryStatus; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record OrderInventoryDto(UUID inventoryId, 10 | UUID orderId, 11 | Integer productId, 12 | Integer quantity, 13 | InventoryStatus status) { 14 | } 15 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /saga-choreography-outbox/inventory-service/src/main/java/com/vinsguru/inventory/common/dto/OrderInventoryDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.common.dto; 2 | 3 | import com.vinsguru.common.events.inventory.InventoryStatus; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | @Builder 9 | public record OrderInventoryDto(UUID inventoryId, 10 | UUID orderId, 11 | Integer productId, 12 | Integer quantity, 13 | InventoryStatus status) { 14 | } 15 | -------------------------------------------------------------------------------- /saga-choreography-outbox/shipping-service/src/main/java/com/vinsguru/shipping/common/service/ShippingService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.common.service; 2 | 3 | import com.vinsguru.shipping.common.dto.ScheduleRequest; 4 | import com.vinsguru.shipping.common.dto.ShipmentDto; 5 | import reactor.core.publisher.Mono; 6 | 7 | import java.util.UUID; 8 | 9 | public interface ShippingService { 10 | 11 | Mono addShipment(ScheduleRequest request); 12 | 13 | Mono cancel(UUID orderId); 14 | 15 | Mono schedule(UUID orderId); 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /project-templates/saga-choreography/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/messages/shipping/ShippingRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.messages.shipping; 2 | 3 | import com.vinsguru.common.messages.Request; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | public sealed interface ShippingRequest extends Request { 9 | 10 | @Builder 11 | record Schedule(UUID orderId, 12 | Integer customerId, 13 | Integer productId, 14 | Integer quantity) implements ShippingRequest { 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/orchestrator/WorkflowStep.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.orchestrator; 2 | 3 | import com.vinsguru.common.messages.Response; 4 | 5 | public interface WorkflowStep extends 6 | RequestSender, 7 | RequestCompensator, 8 | ResponseProcessor, 9 | WorkflowChain { 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/common/enums/WorkflowAction.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.enums; 2 | 3 | public enum WorkflowAction { 4 | 5 | // payment 6 | PAYMENT_REQUEST_INITIATED, 7 | PAYMENT_PROCESSED, 8 | PAYMENT_DECLINED, 9 | PAYMENT_REFUND_INITIATED, 10 | 11 | // inventory 12 | INVENTORY_REQUEST_INITIATED, 13 | INVENTORY_DEDUCTED, 14 | INVENTORY_DECLINED, 15 | INVENTORY_RESTORE_INITIATED, 16 | 17 | // shipping 18 | SHIPPING_SCHEDULE_INITIATED, 19 | SHIPPING_SCHEDULED, 20 | SHIPPING_DECLINED 21 | 22 | } 23 | -------------------------------------------------------------------------------- /saga-orchestrator/shipping-service/src/main/java/com/vinsguru/shipping/application/repository/ShipmentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.application.repository; 2 | 3 | import com.vinsguru.shipping.application.entity.Shipment; 4 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | import reactor.core.publisher.Mono; 7 | 8 | import java.util.UUID; 9 | 10 | @Repository 11 | public interface ShipmentRepository extends ReactiveCrudRepository { 12 | 13 | Mono existsByOrderId(UUID orderId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/CloudStreamKafkaPlaygroundApplication.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication(scanBasePackages = "com.vinsguru.cloudstreamkafkaplayground.${sec}") 7 | public class CloudStreamKafkaPlaygroundApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(CloudStreamKafkaPlaygroundApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /kafka-setup/compose/props/server.properties: -------------------------------------------------------------------------------- 1 | process.roles=broker,controller 2 | node.id=1 3 | listeners=PLAINTEXT://:9092,CONTROLLER://:9093 4 | controller.listener.names=CONTROLLER 5 | advertised.listeners=PLAINTEXT://localhost:9092 6 | inter.broker.listener.name=PLAINTEXT 7 | controller.quorum.voters=1@kafka:9093 8 | listener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL 9 | auto.create.topics.enable=true 10 | offsets.topic.replication.factor=1 11 | transaction.state.log.replication.factor=1 12 | transaction.state.log.min.isr=1 13 | log.dirs=/tmp/kafka-logs -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/application/repository/OrderPaymentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.repository; 2 | 3 | import com.vinsguru.order.application.entity.OrderPayment; 4 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | import reactor.core.publisher.Mono; 7 | 8 | import java.util.UUID; 9 | 10 | @Repository 11 | public interface OrderPaymentRepository extends ReactiveCrudRepository { 12 | 13 | Mono findByOrderId(UUID orderId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/application/repository/OrderPaymentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.repository; 2 | 3 | import com.vinsguru.order.application.entity.OrderPayment; 4 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | import reactor.core.publisher.Mono; 7 | 8 | import java.util.UUID; 9 | 10 | @Repository 11 | public interface OrderPaymentRepository extends ReactiveCrudRepository { 12 | 13 | Mono findByOrderId(UUID orderId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/application/repository/OrderInventoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.repository; 2 | 3 | import com.vinsguru.order.application.entity.OrderInventory; 4 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | import reactor.core.publisher.Mono; 7 | 8 | import java.util.UUID; 9 | 10 | @Repository 11 | public interface OrderInventoryRepository extends ReactiveCrudRepository { 12 | 13 | Mono findByOrderId(UUID orderId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/messages/inventory/InventoryRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.messages.inventory; 2 | 3 | import com.vinsguru.common.messages.Request; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | public sealed interface InventoryRequest extends Request { 9 | 10 | @Builder 11 | record Deduct(UUID orderId, 12 | Integer productId, 13 | Integer quantity) implements InventoryRequest { 14 | 15 | } 16 | 17 | @Builder 18 | record Restore(UUID orderId) implements InventoryRequest { 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/application/repository/OrderInventoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.repository; 2 | 3 | import com.vinsguru.order.application.entity.OrderInventory; 4 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | import reactor.core.publisher.Mono; 7 | 8 | import java.util.UUID; 9 | 10 | @Repository 11 | public interface OrderInventoryRepository extends ReactiveCrudRepository { 12 | 13 | Mono findByOrderId(UUID orderId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS customer; 2 | DROP TABLE IF EXISTS customer_payment; 3 | 4 | CREATE TABLE customer ( 5 | id int AUTO_INCREMENT primary key, 6 | name VARCHAR(50) NOT NULL, 7 | balance int 8 | ); 9 | 10 | CREATE TABLE customer_payment ( 11 | payment_id uuid default random_uuid() primary key, 12 | order_id uuid, 13 | customer_id int, 14 | status VARCHAR(50), 15 | amount int, 16 | foreign key (customer_id) references customer(id) 17 | ); 18 | 19 | insert into customer(name, balance) 20 | values 21 | ('sam', 100), 22 | ('mike', 100), 23 | ('john', 100); -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS customer; 2 | DROP TABLE IF EXISTS customer_payment; 3 | 4 | CREATE TABLE customer ( 5 | id int AUTO_INCREMENT primary key, 6 | name VARCHAR(50) NOT NULL, 7 | balance int 8 | ); 9 | 10 | CREATE TABLE customer_payment ( 11 | payment_id uuid default random_uuid() primary key, 12 | order_id uuid, 13 | customer_id int, 14 | status VARCHAR(50), 15 | amount int, 16 | foreign key (customer_id) references customer(id) 17 | ); 18 | 19 | insert into customer(name, balance) 20 | values 21 | ('sam', 100), 22 | ('mike', 100), 23 | ('john', 100); -------------------------------------------------------------------------------- /saga-choreography/shipping-service/src/main/java/com/vinsguru/shipping/common/dto/ShipmentDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.common.dto; 2 | 3 | import com.vinsguru.common.events.shipping.ShippingStatus; 4 | import lombok.Builder; 5 | 6 | import java.time.Instant; 7 | import java.util.UUID; 8 | 9 | @Builder 10 | public record ShipmentDto(UUID shipmentId, 11 | UUID orderId, 12 | Integer productId, 13 | Integer customerId, 14 | Integer quantity, 15 | Instant expectedDelivery, 16 | ShippingStatus status) { 17 | } 18 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS order_workflow_action; 2 | DROP TABLE IF EXISTS purchase_order; 3 | 4 | CREATE TABLE purchase_order ( 5 | order_id uuid default random_uuid() primary key, 6 | customer_id int, 7 | product_id int, 8 | quantity int, 9 | unit_price int, 10 | amount int, 11 | status VARCHAR(100), 12 | delivery_date TIMESTAMP 13 | ); 14 | 15 | CREATE TABLE order_workflow_action ( 16 | id uuid default random_uuid() primary key, 17 | order_id uuid, 18 | action VARCHAR(100), 19 | created_at TIMESTAMP, 20 | foreign key (order_id) references purchase_order(order_id) 21 | ); 22 | -------------------------------------------------------------------------------- /saga-orchestrator/shipping-service/src/main/java/com/vinsguru/shipping/common/dto/ShipmentDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.common.dto; 2 | 3 | import com.vinsguru.common.messages.shipping.ShippingStatus; 4 | import lombok.Builder; 5 | 6 | import java.time.Instant; 7 | import java.util.UUID; 8 | 9 | @Builder 10 | public record ShipmentDto(UUID shipmentId, 11 | UUID orderId, 12 | Integer productId, 13 | Integer customerId, 14 | Integer quantity, 15 | Instant deliveryDate, 16 | ShippingStatus status) { 17 | } 18 | -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS customer; 2 | DROP TABLE IF EXISTS customer_payment; 3 | 4 | CREATE TABLE customer ( 5 | id int AUTO_INCREMENT primary key, 6 | name VARCHAR(50) NOT NULL, 7 | balance int 8 | ); 9 | 10 | CREATE TABLE customer_payment ( 11 | payment_id uuid default random_uuid() primary key, 12 | order_id uuid, 13 | customer_id int, 14 | status VARCHAR(50), 15 | amount int, 16 | foreign key (customer_id) references customer(id) 17 | ); 18 | 19 | insert into customer(name, balance) 20 | values 21 | ('sam', 100), 22 | ('mike', 100), 23 | ('john', 100); -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/common/service/OrderFulfillmentService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import com.vinsguru.order.common.dto.OrderShipmentSchedule; 4 | import com.vinsguru.order.common.dto.PurchaseOrderDto; 5 | import reactor.core.publisher.Mono; 6 | 7 | import java.util.UUID; 8 | 9 | public interface OrderFulfillmentService { 10 | 11 | Mono get(UUID orderId); 12 | 13 | Mono schedule(OrderShipmentSchedule shipmentSchedule); 14 | 15 | Mono complete(UUID orderId); 16 | 17 | Mono cancel(UUID orderId); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /saga-choreography-outbox/shipping-service/src/main/java/com/vinsguru/shipping/common/dto/ShipmentDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.common.dto; 2 | 3 | import com.vinsguru.common.events.shipping.ShippingStatus; 4 | import lombok.Builder; 5 | 6 | import java.time.Instant; 7 | import java.util.UUID; 8 | 9 | @Builder 10 | public record ShipmentDto(UUID shipmentId, 11 | UUID orderId, 12 | Integer productId, 13 | Integer customerId, 14 | Integer quantity, 15 | Instant expectedDelivery, 16 | ShippingStatus status) { 17 | } 18 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import com.vinsguru.order.common.dto.OrderCreateRequest; 4 | import com.vinsguru.order.common.dto.OrderDetails; 5 | import com.vinsguru.order.common.dto.PurchaseOrderDto; 6 | import reactor.core.publisher.Flux; 7 | import reactor.core.publisher.Mono; 8 | 9 | import java.util.UUID; 10 | 11 | public interface OrderService { 12 | 13 | Mono placeOrder(OrderCreateRequest request); 14 | 15 | Flux getAllOrders(); 16 | 17 | Mono getOrderDetails(UUID orderId); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/common/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import com.vinsguru.order.common.dto.OrderCreateRequest; 4 | import com.vinsguru.order.common.dto.OrderDetails; 5 | import com.vinsguru.order.common.dto.PurchaseOrderDto; 6 | import reactor.core.publisher.Flux; 7 | import reactor.core.publisher.Mono; 8 | 9 | import java.util.UUID; 10 | 11 | public interface OrderService { 12 | 13 | Mono placeOrder(OrderCreateRequest request); 14 | 15 | Flux getAllOrders(); 16 | 17 | Mono getOrderDetails(UUID orderId); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.service; 2 | 3 | import com.vinsguru.order.common.dto.OrderCreateRequest; 4 | import com.vinsguru.order.common.dto.OrderDetails; 5 | import com.vinsguru.order.common.dto.PurchaseOrderDto; 6 | import reactor.core.publisher.Flux; 7 | import reactor.core.publisher.Mono; 8 | 9 | import java.util.UUID; 10 | 11 | public interface OrderService { 12 | 13 | Mono placeOrder(OrderCreateRequest request); 14 | 15 | Flux getAllOrders(); 16 | 17 | Mono getOrderDetails(UUID orderId); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /saga-choreography/inventory-service/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS product; 2 | DROP TABLE IF EXISTS order_inventory; 3 | 4 | CREATE TABLE product ( 5 | id int AUTO_INCREMENT primary key, 6 | description VARCHAR(50), 7 | available_quantity int 8 | ); 9 | 10 | CREATE TABLE order_inventory ( 11 | inventory_id uuid default random_uuid() primary key, 12 | order_id uuid, 13 | product_id int, 14 | status VARCHAR(50), 15 | quantity int, 16 | foreign key (product_id) references product(id) 17 | ); 18 | 19 | insert into product(description, available_quantity) 20 | values 21 | ('book', 10), 22 | ('pen', 10), 23 | ('rug', 10); -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS product; 2 | DROP TABLE IF EXISTS order_inventory; 3 | 4 | CREATE TABLE product ( 5 | id int AUTO_INCREMENT primary key, 6 | description VARCHAR(50), 7 | available_quantity int 8 | ); 9 | 10 | CREATE TABLE order_inventory ( 11 | inventory_id uuid default random_uuid() primary key, 12 | order_id uuid, 13 | product_id int, 14 | status VARCHAR(50), 15 | quantity int, 16 | foreign key (product_id) references product(id) 17 | ); 18 | 19 | insert into product(description, available_quantity) 20 | values 21 | ('book', 10), 22 | ('pen', 10), 23 | ('rug', 10); -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/test/java/com/vinsguru/order/TestDataUtil.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order; 2 | 3 | import com.vinsguru.order.common.dto.OrderCreateRequest; 4 | 5 | public class TestDataUtil { 6 | 7 | public static OrderCreateRequest toRequest(int customerId, int productId, int unitPrice, int quantity) { 8 | return OrderCreateRequest.builder() 9 | .unitPrice(unitPrice) 10 | .quantity(quantity) 11 | .customerId(customerId) 12 | .productId(productId) 13 | .build(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /saga-choreography-outbox/inventory-service/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS product; 2 | DROP TABLE IF EXISTS order_inventory; 3 | 4 | CREATE TABLE product ( 5 | id int AUTO_INCREMENT primary key, 6 | description VARCHAR(50), 7 | available_quantity int 8 | ); 9 | 10 | CREATE TABLE order_inventory ( 11 | inventory_id uuid default random_uuid() primary key, 12 | order_id uuid, 13 | product_id int, 14 | status VARCHAR(50), 15 | quantity int, 16 | foreign key (product_id) references product(id) 17 | ); 18 | 19 | insert into product(description, available_quantity) 20 | values 21 | ('book', 10), 22 | ('pen', 10), 23 | ('rug', 10); -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/messaging/entity/OrderOutbox.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.messaging.entity; 2 | 3 | import com.vinsguru.common.events.order.OrderStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.time.Instant; 11 | 12 | @Data 13 | @Builder 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class OrderOutbox { 17 | 18 | @Id 19 | private Long id; 20 | private byte[] message; 21 | private OrderStatus status; 22 | private Instant createdAt; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /saga-choreography/order-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-orchestrator/order-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/messaging/mapper/ShippingEventMapper.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.messaging.mapper; 2 | 3 | 4 | import com.vinsguru.common.events.shipping.ShippingEvent; 5 | import com.vinsguru.order.common.dto.OrderShipmentSchedule; 6 | 7 | public class ShippingEventMapper { 8 | 9 | public static OrderShipmentSchedule toDto(ShippingEvent.ShippingScheduled event) { 10 | return OrderShipmentSchedule.builder() 11 | .orderId(event.orderId()) 12 | .deliveryDate(event.expectedDelivery()) 13 | .build(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-choreography/inventory-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-choreography/shipping-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-orchestrator/shipping-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-choreography-outbox/shipping-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-choreography/choreography-common/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/messaging/mapper/ShippingEventMapper.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.messaging.mapper; 2 | 3 | 4 | import com.vinsguru.common.events.shipping.ShippingEvent; 5 | import com.vinsguru.order.common.dto.OrderShipmentSchedule; 6 | 7 | public class ShippingEventMapper { 8 | 9 | public static OrderShipmentSchedule toDto(ShippingEvent.ShippingScheduled event) { 10 | return OrderShipmentSchedule.builder() 11 | .orderId(event.orderId()) 12 | .deliveryDate(event.expectedDelivery()) 13 | .build(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-choreography-outbox/inventory-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/events/shipping/ShippingEvent.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events.shipping; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import com.vinsguru.common.events.OrderSaga; 5 | import lombok.Builder; 6 | 7 | import java.time.Instant; 8 | import java.util.UUID; 9 | 10 | public sealed interface ShippingEvent extends DomainEvent, OrderSaga { 11 | 12 | @Builder 13 | record ShippingScheduled(UUID orderId, 14 | UUID shipmentId, 15 | Instant expectedDelivery, 16 | Instant createdAt) implements ShippingEvent { 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/test/java/com/vinsguru/order/TestDataUtil.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order; 2 | 3 | import com.vinsguru.order.common.dto.OrderCreateRequest; 4 | 5 | public class TestDataUtil { 6 | 7 | public static OrderCreateRequest toRequest(int customerId, int productId, int unitPrice, int quantity) { 8 | return OrderCreateRequest.builder() 9 | .unitPrice(unitPrice) 10 | .quantity(quantity) 11 | .customerId(customerId) 12 | .productId(productId) 13 | .build(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/test/java/com/vinsguru/order/TestDataUtil.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order; 2 | 3 | import com.vinsguru.order.common.dto.OrderCreateRequest; 4 | 5 | public class TestDataUtil { 6 | 7 | public static OrderCreateRequest toRequest(int customerId, int productId, int unitPrice, int quantity) { 8 | return OrderCreateRequest.builder() 9 | .unitPrice(unitPrice) 10 | .quantity(quantity) 11 | .customerId(customerId) 12 | .productId(productId) 13 | .build(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /project-templates/saga-choreography/order-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/order-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/resources/application-sec11.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | function: 4 | definition: consumer 5 | stream: 6 | default: 7 | producer: 8 | useNativeEncoding: true 9 | bindings: 10 | consumer-in-0: 11 | destination: input-topic 12 | group: some-group 13 | kafka: 14 | binder: 15 | consumer-properties: 16 | "value.deserializer": org.springframework.kafka.support.serializer.JsonDeserializer 17 | "auto.offset.reset": "earliest" 18 | "group.instance.id": "1" 19 | "spring.json.trusted.packages": "com.vinsguru.cloudstreamkafkaplayground.sec11.dto" 20 | -------------------------------------------------------------------------------- /project-templates/saga-choreography/choreography-common/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /project-templates/saga-choreography/customer-payment/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /project-templates/saga-choreography/inventory-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /project-templates/saga-choreography/shipping-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/customer-payment/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/inventory-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/orchestrator-common/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /project-templates/saga-orchestrator/shipping-service/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/events/shipping/ShippingEvent.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.events.shipping; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import com.vinsguru.common.events.OrderSaga; 5 | import lombok.Builder; 6 | 7 | import java.time.Instant; 8 | import java.util.UUID; 9 | 10 | public sealed interface ShippingEvent extends DomainEvent, OrderSaga { 11 | 12 | @Builder 13 | record ShippingScheduled(UUID orderId, 14 | UUID shipmentId, 15 | Instant expectedDelivery, 16 | Instant createdAt) implements ShippingEvent { 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/util/MessageConverter.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.util; 2 | 3 | import org.springframework.kafka.support.KafkaHeaders; 4 | import org.springframework.messaging.Message; 5 | import reactor.kafka.receiver.ReceiverOffset; 6 | 7 | public class MessageConverter { 8 | 9 | public static Record toRecord(Message message) { 10 | var payload = message.getPayload(); 11 | var key = message.getHeaders().get(KafkaHeaders.RECEIVED_KEY, String.class); 12 | var ack = message.getHeaders().get(KafkaHeaders.ACKNOWLEDGMENT, ReceiverOffset.class); 13 | return new Record<>(key, payload, ack); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/util/MessageConverter.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.util; 2 | 3 | import org.springframework.kafka.support.KafkaHeaders; 4 | import org.springframework.messaging.Message; 5 | import reactor.kafka.receiver.ReceiverOffset; 6 | 7 | public class MessageConverter { 8 | 9 | public static Record toRecord(Message message) { 10 | var payload = message.getPayload(); 11 | var key = message.getHeaders().get(KafkaHeaders.RECEIVED_KEY, String.class); 12 | var ack = message.getHeaders().get(KafkaHeaders.ACKNOWLEDGMENT, ReceiverOffset.class); 13 | return new Record<>(key, payload, ack); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/application/repository/PurchaseOrderRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.repository; 2 | 3 | import com.vinsguru.order.application.entity.PurchaseOrder; 4 | import com.vinsguru.order.common.enums.OrderStatus; 5 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 6 | import org.springframework.stereotype.Repository; 7 | import reactor.core.publisher.Mono; 8 | 9 | import java.util.UUID; 10 | 11 | @Repository 12 | public interface PurchaseOrderRepository extends ReactiveCrudRepository { 13 | 14 | Mono findByOrderIdAndStatus(UUID orderId, OrderStatus status); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/resources/application-sec04.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | function: 4 | definition: producer;consumer 5 | stream: 6 | bindings: 7 | consumer-in-0: 8 | destination: input-topic 9 | group: some-group 10 | producer-out-0: 11 | destination: input-topic 12 | kafka: 13 | binder: 14 | producer-properties: 15 | "key.serializer": org.apache.kafka.common.serialization.StringSerializer 16 | consumer-properties: 17 | "key.deserializer": org.apache.kafka.common.serialization.StringDeserializer 18 | "auto.offset.reset": "earliest" 19 | "group.instance.id": "1" -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/util/MessageConverter.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.util; 2 | 3 | import org.springframework.kafka.support.KafkaHeaders; 4 | import org.springframework.messaging.Message; 5 | import reactor.kafka.receiver.ReceiverOffset; 6 | 7 | public class MessageConverter { 8 | 9 | public static Record toRecord(Message message) { 10 | var payload = message.getPayload(); 11 | var key = message.getHeaders().get(KafkaHeaders.RECEIVED_KEY, String.class); 12 | var ack = message.getHeaders().get(KafkaHeaders.ACKNOWLEDGMENT, ReceiverOffset.class); 13 | return new Record<>(key, payload, ack); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/test/java/com/vinsguru/payment/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment; 2 | 3 | import org.springframework.boot.test.context.SpringBootTest; 4 | import org.springframework.kafka.test.context.EmbeddedKafka; 5 | import org.springframework.test.annotation.DirtiesContext; 6 | 7 | @DirtiesContext 8 | @SpringBootTest(properties = { 9 | "logging.level.root=ERROR", 10 | "logging.level.com.vinsguru*=INFO", 11 | "spring.cloud.stream.kafka.binder.configuration.auto.offset.reset=earliest" 12 | }) 13 | @EmbeddedKafka( 14 | partitions = 1, 15 | bootstrapServersProperty = "spring.kafka.bootstrap-servers" 16 | ) 17 | public abstract class AbstractIntegrationTest { 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/test/java/com/vinsguru/payment/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment; 2 | 3 | import org.springframework.boot.test.context.SpringBootTest; 4 | import org.springframework.kafka.test.context.EmbeddedKafka; 5 | import org.springframework.test.annotation.DirtiesContext; 6 | 7 | @DirtiesContext 8 | @SpringBootTest(properties = { 9 | "logging.level.root=ERROR", 10 | "logging.level.com.vinsguru*=INFO", 11 | "spring.cloud.stream.kafka.binder.configuration.auto.offset.reset=earliest" 12 | }) 13 | @EmbeddedKafka( 14 | partitions = 1, 15 | bootstrapServersProperty = "spring.kafka.bootstrap-servers" 16 | ) 17 | public abstract class AbstractIntegrationTest { 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /kafka-setup/image/runner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # If env variable not set, generate random one 4 | # Large organizations might have multiple kafka clusters. Each cluster is expected to have an ID 5 | clusterId=${KAFKA_CLUSTER_ID:-$(kafka-storage.sh random-uuid)} 6 | echo "Kafka Cluster ID : ${clusterId}" 7 | 8 | # For the first time, format the storage. It would create couple of files (meta.properties, checkpoint file). 9 | # If it is already formatted, it would be ignored. 10 | 11 | echo "Formatting storage" 12 | kafka-storage.sh format -t $clusterId -c /kafka/config/kraft/server.properties 13 | 14 | # Finally start the kafka server!! 15 | 16 | echo "Starting Kafka" 17 | exec kafka-server-start.sh /kafka/config/kraft/server.properties -------------------------------------------------------------------------------- /saga-choreography/inventory-service/src/test/java/com/vinsguru/inventory/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory; 2 | 3 | import org.springframework.boot.test.context.SpringBootTest; 4 | import org.springframework.kafka.test.context.EmbeddedKafka; 5 | import org.springframework.test.annotation.DirtiesContext; 6 | 7 | @DirtiesContext 8 | @SpringBootTest(properties = { 9 | "logging.level.root=ERROR", 10 | "logging.level.com.vinsguru*=INFO", 11 | "spring.cloud.stream.kafka.binder.configuration.auto.offset.reset=earliest" 12 | }) 13 | @EmbeddedKafka( 14 | partitions = 1, 15 | bootstrapServersProperty = "spring.kafka.bootstrap-servers" 16 | ) 17 | public abstract class AbstractIntegrationTest { 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-choreography/shipping-service/src/test/java/com/vinsguru/shipping/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping; 2 | 3 | import org.springframework.boot.test.context.SpringBootTest; 4 | import org.springframework.kafka.test.context.EmbeddedKafka; 5 | import org.springframework.test.annotation.DirtiesContext; 6 | 7 | @DirtiesContext 8 | @SpringBootTest(properties = { 9 | "logging.level.root=ERROR", 10 | "logging.level.com.vinsguru*=INFO", 11 | "spring.cloud.stream.kafka.binder.configuration.auto.offset.reset=earliest" 12 | }) 13 | @EmbeddedKafka( 14 | partitions = 1, 15 | bootstrapServersProperty = "spring.kafka.bootstrap-servers" 16 | ) 17 | public abstract class AbstractIntegrationTest { 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/test/java/com/vinsguru/inventory/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory; 2 | 3 | import org.springframework.boot.test.context.SpringBootTest; 4 | import org.springframework.kafka.test.context.EmbeddedKafka; 5 | import org.springframework.test.annotation.DirtiesContext; 6 | 7 | @DirtiesContext 8 | @SpringBootTest(properties = { 9 | "logging.level.root=ERROR", 10 | "logging.level.com.vinsguru*=INFO", 11 | "spring.cloud.stream.kafka.binder.configuration.auto.offset.reset=earliest" 12 | }) 13 | @EmbeddedKafka( 14 | partitions = 1, 15 | bootstrapServersProperty = "spring.kafka.bootstrap-servers" 16 | ) 17 | public abstract class AbstractIntegrationTest { 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/application/entity/OrderWorkflowAction.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.entity; 2 | 3 | import com.vinsguru.order.common.enums.WorkflowAction; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.time.Instant; 11 | import java.util.UUID; 12 | 13 | @Data 14 | @Builder 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class OrderWorkflowAction { 18 | 19 | @Id 20 | private UUID id; 21 | private UUID orderId; 22 | private WorkflowAction action; 23 | private Instant createdAt; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/common/dto/PurchaseOrderDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import com.vinsguru.order.common.enums.OrderStatus; 4 | import lombok.Builder; 5 | 6 | import java.time.Instant; 7 | import java.util.UUID; 8 | 9 | @Builder 10 | public record PurchaseOrderDto(UUID orderId, 11 | Integer customerId, 12 | Integer productId, 13 | Integer unitPrice, 14 | Integer quantity, 15 | Integer amount, 16 | OrderStatus status, 17 | Instant deliveryDate) { 18 | } 19 | -------------------------------------------------------------------------------- /saga-orchestrator/shipping-service/src/test/java/com/vinsguru/shipping/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping; 2 | 3 | import org.springframework.boot.test.context.SpringBootTest; 4 | import org.springframework.kafka.test.context.EmbeddedKafka; 5 | import org.springframework.test.annotation.DirtiesContext; 6 | 7 | @DirtiesContext 8 | @SpringBootTest(properties = { 9 | "logging.level.root=ERROR", 10 | "logging.level.com.vinsguru*=INFO", 11 | "spring.cloud.stream.kafka.binder.configuration.auto.offset.reset=earliest" 12 | }) 13 | @EmbeddedKafka( 14 | partitions = 1, 15 | bootstrapServersProperty = "spring.kafka.bootstrap-servers" 16 | ) 17 | public abstract class AbstractIntegrationTest { 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/test/java/com/vinsguru/payment/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment; 2 | 3 | import org.springframework.boot.test.context.SpringBootTest; 4 | import org.springframework.kafka.test.context.EmbeddedKafka; 5 | import org.springframework.test.annotation.DirtiesContext; 6 | 7 | @DirtiesContext 8 | @SpringBootTest(properties = { 9 | "logging.level.root=ERROR", 10 | "logging.level.com.vinsguru*=INFO", 11 | "spring.cloud.stream.kafka.binder.configuration.auto.offset.reset=earliest" 12 | }) 13 | @EmbeddedKafka( 14 | partitions = 1, 15 | bootstrapServersProperty = "spring.kafka.bootstrap-servers" 16 | ) 17 | public abstract class AbstractIntegrationTest { 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-choreography-outbox/shipping-service/src/test/java/com/vinsguru/shipping/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping; 2 | 3 | import org.springframework.boot.test.context.SpringBootTest; 4 | import org.springframework.kafka.test.context.EmbeddedKafka; 5 | import org.springframework.test.annotation.DirtiesContext; 6 | 7 | @DirtiesContext 8 | @SpringBootTest(properties = { 9 | "logging.level.root=ERROR", 10 | "logging.level.com.vinsguru*=INFO", 11 | "spring.cloud.stream.kafka.binder.configuration.auto.offset.reset=earliest" 12 | }) 13 | @EmbeddedKafka( 14 | partitions = 1, 15 | bootstrapServersProperty = "spring.kafka.bootstrap-servers" 16 | ) 17 | public abstract class AbstractIntegrationTest { 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/common/dto/PurchaseOrderDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import com.vinsguru.common.events.order.OrderStatus; 4 | import lombok.Builder; 5 | 6 | import java.time.Instant; 7 | import java.util.UUID; 8 | 9 | @Builder 10 | public record PurchaseOrderDto(UUID orderId, 11 | Integer customerId, 12 | Integer productId, 13 | Integer unitPrice, 14 | Integer quantity, 15 | Integer amount, 16 | OrderStatus status, 17 | Instant deliveryDate) { 18 | } 19 | -------------------------------------------------------------------------------- /saga-choreography-outbox/inventory-service/src/test/java/com/vinsguru/inventory/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory; 2 | 3 | import org.springframework.boot.test.context.SpringBootTest; 4 | import org.springframework.kafka.test.context.EmbeddedKafka; 5 | import org.springframework.test.annotation.DirtiesContext; 6 | 7 | @DirtiesContext 8 | @SpringBootTest(properties = { 9 | "logging.level.root=ERROR", 10 | "logging.level.com.vinsguru*=INFO", 11 | "spring.cloud.stream.kafka.binder.configuration.auto.offset.reset=earliest" 12 | }) 13 | @EmbeddedKafka( 14 | partitions = 1, 15 | bootstrapServersProperty = "spring.kafka.bootstrap-servers" 16 | ) 17 | public abstract class AbstractIntegrationTest { 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/common/dto/PurchaseOrderDto.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.common.dto; 2 | 3 | import com.vinsguru.common.events.order.OrderStatus; 4 | import lombok.Builder; 5 | 6 | import java.time.Instant; 7 | import java.util.UUID; 8 | 9 | @Builder 10 | public record PurchaseOrderDto(UUID orderId, 11 | Integer customerId, 12 | Integer productId, 13 | Integer unitPrice, 14 | Integer quantity, 15 | Integer amount, 16 | OrderStatus status, 17 | Instant deliveryDate) { 18 | } 19 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/main/java/com/vinsguru/payment/application/entity/CustomerPayment.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.application.entity; 2 | 3 | import com.vinsguru.common.events.payment.PaymentStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.util.UUID; 11 | 12 | @Data 13 | @Builder 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class CustomerPayment { 17 | 18 | @Id 19 | private UUID paymentId; 20 | private UUID orderId; 21 | private Integer customerId; 22 | private PaymentStatus status; 23 | private Integer amount; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/main/java/com/vinsguru/payment/application/entity/CustomerPayment.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.application.entity; 2 | 3 | import com.vinsguru.common.messages.payment.PaymentStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.util.UUID; 11 | 12 | @Data 13 | @Builder 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class CustomerPayment { 17 | 18 | @Id 19 | private UUID paymentId; 20 | private UUID orderId; 21 | private Integer customerId; 22 | private PaymentStatus status; 23 | private Integer amount; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/resources/application-sec13.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | function: 4 | definition: producer 5 | stream: 6 | bindings: 7 | producer-out-0: 8 | destination: input-topic 9 | kafka: 10 | binder: 11 | producer-properties: 12 | "key.serializer": org.apache.kafka.common.serialization.StringSerializer 13 | consumer-properties: 14 | "key.deserializer": org.apache.kafka.common.serialization.StringDeserializer 15 | "auto.offset.reset": "earliest" 16 | "group.instance.id": "1" 17 | bindings: 18 | producer-out-0: 19 | producer: 20 | recordMetadataChannel: senderResults -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/main/java/com/vinsguru/payment/application/entity/CustomerPayment.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.application.entity; 2 | 3 | import com.vinsguru.common.events.payment.PaymentStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.util.UUID; 11 | 12 | @Data 13 | @Builder 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class CustomerPayment { 17 | 18 | @Id 19 | private UUID paymentId; 20 | private UUID orderId; 21 | private Integer customerId; 22 | private PaymentStatus status; 23 | private Integer amount; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/common/MessageConverter.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.common; 2 | 3 | import org.springframework.kafka.support.KafkaHeaders; 4 | import org.springframework.messaging.Message; 5 | import reactor.kafka.receiver.ReceiverOffset; 6 | 7 | public class MessageConverter { 8 | 9 | public static Record toRecord(Message message) { 10 | var payload = message.getPayload(); 11 | var key = message.getHeaders().get(KafkaHeaders.RECEIVED_KEY, String.class); 12 | var ack = message.getHeaders().get(KafkaHeaders.ACKNOWLEDGMENT, ReceiverOffset.class); 13 | return new Record<>(key, payload, ack); 14 | } 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /saga-choreography/inventory-service/src/main/java/com/vinsguru/inventory/application/entity/OrderInventory.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.application.entity; 2 | 3 | import com.vinsguru.common.events.inventory.InventoryStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.util.UUID; 11 | 12 | @Data 13 | @Builder 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class OrderInventory { 17 | 18 | @Id 19 | private UUID inventoryId; 20 | private UUID orderId; 21 | private Integer productId; 22 | private Integer quantity; 23 | private InventoryStatus status; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/main/java/com/vinsguru/inventory/application/entity/OrderInventory.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.application.entity; 2 | 3 | import com.vinsguru.common.messages.inventory.InventoryStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.util.UUID; 11 | 12 | @Data 13 | @Builder 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class OrderInventory { 17 | 18 | @Id 19 | private UUID inventoryId; 20 | private UUID orderId; 21 | private Integer productId; 22 | private Integer quantity; 23 | private InventoryStatus status; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /saga-choreography-outbox/inventory-service/src/main/java/com/vinsguru/inventory/application/entity/OrderInventory.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.application.entity; 2 | 3 | import com.vinsguru.common.events.inventory.InventoryStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.util.UUID; 11 | 12 | @Data 13 | @Builder 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class OrderInventory { 17 | 18 | @Id 19 | private UUID inventoryId; 20 | private UUID orderId; 21 | private Integer productId; 22 | private Integer quantity; 23 | private InventoryStatus status; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/listener/ShippingEventListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.listener; 2 | 3 | import com.vinsguru.common.events.shipping.ShippingEvent; 4 | import reactor.core.publisher.Mono; 5 | 6 | public interface ShippingEventListener extends EventListener { 7 | 8 | /* 9 | To follow the same pattern as other event processors. 10 | also for type! 11 | */ 12 | 13 | @Override 14 | default Mono listen(ShippingEvent event) { 15 | return switch (event) { 16 | case ShippingEvent.ShippingScheduled e -> this.handle(e); 17 | }; 18 | } 19 | 20 | Mono handle(ShippingEvent.ShippingScheduled event); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /saga-orchestrator/shipping-service/src/test/java/com/vinsguru/shipping/TestDataUtil.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping; 2 | 3 | import com.vinsguru.common.messages.shipping.ShippingRequest; 4 | 5 | import java.util.UUID; 6 | 7 | public class TestDataUtil { 8 | 9 | public static ShippingRequest.Schedule createScheduleRequest(UUID orderId, int customerId, int productId, int quantity) { 10 | return ShippingRequest.Schedule.builder() 11 | .orderId(orderId) 12 | .customerId(customerId) 13 | .productId(productId) 14 | .quantity(quantity) 15 | .build(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/main/java/com/vinsguru/payment/application/repository/PaymentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.application.repository; 2 | 3 | import com.vinsguru.common.events.payment.PaymentStatus; 4 | import com.vinsguru.payment.application.entity.CustomerPayment; 5 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 6 | import org.springframework.stereotype.Repository; 7 | import reactor.core.publisher.Mono; 8 | 9 | import java.util.UUID; 10 | 11 | @Repository 12 | public interface PaymentRepository extends ReactiveCrudRepository { 13 | 14 | Mono existsByOrderId(UUID orderId); 15 | 16 | Mono findByOrderIdAndStatus(UUID orderId, PaymentStatus status); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/main/java/com/vinsguru/payment/application/repository/PaymentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.application.repository; 2 | 3 | import com.vinsguru.common.messages.payment.PaymentStatus; 4 | import com.vinsguru.payment.application.entity.CustomerPayment; 5 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 6 | import org.springframework.stereotype.Repository; 7 | import reactor.core.publisher.Mono; 8 | 9 | import java.util.UUID; 10 | 11 | @Repository 12 | public interface PaymentRepository extends ReactiveCrudRepository { 13 | 14 | Mono existsByOrderId(UUID orderId); 15 | 16 | Mono findByOrderIdAndStatus(UUID orderId, PaymentStatus status); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/main/java/com/vinsguru/payment/application/repository/PaymentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.application.repository; 2 | 3 | import com.vinsguru.common.events.payment.PaymentStatus; 4 | import com.vinsguru.payment.application.entity.CustomerPayment; 5 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 6 | import org.springframework.stereotype.Repository; 7 | import reactor.core.publisher.Mono; 8 | 9 | import java.util.UUID; 10 | 11 | @Repository 12 | public interface PaymentRepository extends ReactiveCrudRepository { 13 | 14 | Mono existsByOrderId(UUID orderId); 15 | 16 | Mono findByOrderIdAndStatus(UUID orderId, PaymentStatus status); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/messages/payment/PaymentRequest.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.messages.payment; 2 | 3 | import com.vinsguru.common.messages.Request; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | public sealed interface PaymentRequest extends Request { 9 | 10 | /* 11 | Intentionally named as Process / Processed as these are inner classes. 12 | Feel free to change if you do not like it 13 | */ 14 | 15 | @Builder 16 | record Process(UUID orderId, 17 | Integer customerId, 18 | Integer amount) implements PaymentRequest { 19 | } 20 | 21 | @Builder 22 | record Refund(UUID orderId) implements PaymentRequest { 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /saga-choreography/inventory-service/src/main/java/com/vinsguru/inventory/application/repository/InventoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.application.repository; 2 | 3 | 4 | import com.vinsguru.common.events.inventory.InventoryStatus; 5 | import com.vinsguru.inventory.application.entity.OrderInventory; 6 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 7 | import org.springframework.stereotype.Repository; 8 | import reactor.core.publisher.Mono; 9 | 10 | import java.util.UUID; 11 | 12 | @Repository 13 | public interface InventoryRepository extends ReactiveCrudRepository { 14 | 15 | Mono existsByOrderId(UUID orderId); 16 | 17 | Mono findByOrderIdAndStatus(UUID orderId, InventoryStatus status); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/main/java/com/vinsguru/inventory/application/repository/InventoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.application.repository; 2 | 3 | 4 | import com.vinsguru.common.messages.inventory.InventoryStatus; 5 | import com.vinsguru.inventory.application.entity.OrderInventory; 6 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 7 | import org.springframework.stereotype.Repository; 8 | import reactor.core.publisher.Mono; 9 | 10 | import java.util.UUID; 11 | 12 | @Repository 13 | public interface InventoryRepository extends ReactiveCrudRepository { 14 | 15 | Mono existsByOrderId(UUID orderId); 16 | 17 | Mono findByOrderIdAndStatus(UUID orderId, InventoryStatus status); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /saga-choreography-outbox/inventory-service/src/main/java/com/vinsguru/inventory/application/repository/InventoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.application.repository; 2 | 3 | 4 | import com.vinsguru.common.events.inventory.InventoryStatus; 5 | import com.vinsguru.inventory.application.entity.OrderInventory; 6 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 7 | import org.springframework.stereotype.Repository; 8 | import reactor.core.publisher.Mono; 9 | 10 | import java.util.UUID; 11 | 12 | @Repository 13 | public interface InventoryRepository extends ReactiveCrudRepository { 14 | 15 | Mono existsByOrderId(UUID orderId); 16 | 17 | Mono findByOrderIdAndStatus(UUID orderId, InventoryStatus status); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /saga-choreography/shipping-service/src/main/java/com/vinsguru/shipping/application/repository/ShipmentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.application.repository; 2 | 3 | import com.vinsguru.common.events.shipping.ShippingStatus; 4 | import com.vinsguru.shipping.application.entity.Shipment; 5 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 6 | import org.springframework.stereotype.Repository; 7 | import reactor.core.publisher.Mono; 8 | 9 | import java.util.UUID; 10 | 11 | @Repository 12 | public interface ShipmentRepository extends ReactiveCrudRepository { 13 | 14 | Mono existsByOrderId(UUID orderId); 15 | 16 | Mono findByOrderIdAndStatus(UUID orderId, ShippingStatus status); 17 | 18 | Mono deleteByOrderId(UUID orderId); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/messaging/config/OrderEventListenerConfig.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.messaging.config; 2 | 3 | import com.vinsguru.order.common.service.OrderEventListener; 4 | import com.vinsguru.order.messaging.publisher.OrderEventListenerImpl; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import reactor.core.publisher.Sinks; 8 | 9 | import java.util.UUID; 10 | 11 | @Configuration 12 | public class OrderEventListenerConfig { 13 | 14 | @Bean 15 | public OrderEventListener orderEventListener(){ 16 | var sink = Sinks.many().unicast().onBackpressureBuffer(); 17 | var flux = sink.asFlux(); 18 | return new OrderEventListenerImpl(sink, flux); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /saga-choreography-outbox/shipping-service/src/main/java/com/vinsguru/shipping/application/repository/ShipmentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.application.repository; 2 | 3 | import com.vinsguru.common.events.shipping.ShippingStatus; 4 | import com.vinsguru.shipping.application.entity.Shipment; 5 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 6 | import org.springframework.stereotype.Repository; 7 | import reactor.core.publisher.Mono; 8 | 9 | import java.util.UUID; 10 | 11 | @Repository 12 | public interface ShipmentRepository extends ReactiveCrudRepository { 13 | 14 | Mono existsByOrderId(UUID orderId); 15 | 16 | Mono findByOrderIdAndStatus(UUID orderId, ShippingStatus status); 17 | 18 | Mono deleteByOrderId(UUID orderId); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/processor/ShippingEventProcessor.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.processor; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import com.vinsguru.common.events.shipping.ShippingEvent; 5 | import reactor.core.publisher.Mono; 6 | 7 | public interface ShippingEventProcessor extends EventProcessor { 8 | 9 | /* 10 | To follow the same pattern as other event processors. 11 | also for type! 12 | */ 13 | 14 | @Override 15 | default Mono process(ShippingEvent event) { 16 | return switch (event) { 17 | case ShippingEvent.ShippingScheduled e -> this.handle(e); 18 | }; 19 | } 20 | 21 | Mono handle(ShippingEvent.ShippingScheduled event); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /saga-choreography/shipping-service/src/main/java/com/vinsguru/shipping/application/entity/Shipment.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.application.entity; 2 | 3 | import com.vinsguru.common.events.shipping.ShippingStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.time.Instant; 11 | import java.util.UUID; 12 | 13 | @Data 14 | @Builder 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class Shipment { 18 | 19 | @Id 20 | private UUID id; 21 | private UUID orderId; 22 | private Integer productId; 23 | private Integer customerId; 24 | private Integer quantity; 25 | private Instant deliveryDate; 26 | private ShippingStatus status; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /saga-orchestrator/shipping-service/src/main/java/com/vinsguru/shipping/application/entity/Shipment.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.application.entity; 2 | 3 | import com.vinsguru.common.messages.shipping.ShippingStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.time.Instant; 11 | import java.util.UUID; 12 | 13 | @Data 14 | @Builder 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class Shipment { 18 | 19 | @Id 20 | private UUID id; 21 | private UUID orderId; 22 | private Integer productId; 23 | private Integer customerId; 24 | private Integer quantity; 25 | private Instant deliveryDate; 26 | private ShippingStatus status; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /saga-orchestrator/shipping-service/src/main/java/com/vinsguru/shipping/messaging/processor/ShippingRequestProcessor.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.messaging.processor; 2 | 3 | import com.vinsguru.common.messages.shipping.ShippingRequest; 4 | import com.vinsguru.common.messages.shipping.ShippingResponse; 5 | import com.vinsguru.common.processor.RequestProcessor; 6 | import reactor.core.publisher.Mono; 7 | 8 | public interface ShippingRequestProcessor extends RequestProcessor { 9 | 10 | @Override 11 | default Mono process(ShippingRequest request) { 12 | return switch (request){ 13 | case ShippingRequest.Schedule s -> this.handle(s); 14 | }; 15 | } 16 | 17 | Mono handle(ShippingRequest.Schedule request); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /saga-choreography-outbox/shipping-service/src/main/java/com/vinsguru/shipping/application/entity/Shipment.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.shipping.application.entity; 2 | 3 | import com.vinsguru.common.events.shipping.ShippingStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.time.Instant; 11 | import java.util.UUID; 12 | 13 | @Data 14 | @Builder 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class Shipment { 18 | 19 | @Id 20 | private UUID id; 21 | private UUID orderId; 22 | private Integer productId; 23 | private Integer customerId; 24 | private Integer quantity; 25 | private Instant deliveryDate; 26 | private ShippingStatus status; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/application/entity/OrderPayment.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.entity; 2 | 3 | import com.vinsguru.common.events.payment.PaymentStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.util.UUID; 11 | 12 | @Data 13 | @Builder 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class OrderPayment { 17 | 18 | /* 19 | We intentionally maintain 1:1 relationship 20 | */ 21 | 22 | @Id 23 | private Integer id; 24 | private UUID orderId; 25 | private UUID paymentId; 26 | private PaymentStatus status; 27 | private Boolean success; 28 | private String message; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/application/entity/OrderPayment.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.entity; 2 | 3 | import com.vinsguru.common.events.payment.PaymentStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.util.UUID; 11 | 12 | @Data 13 | @Builder 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class OrderPayment { 17 | 18 | /* 19 | We intentionally maintain 1:1 relationship 20 | */ 21 | 22 | @Id 23 | private Integer id; 24 | private UUID orderId; 25 | private UUID paymentId; 26 | private PaymentStatus status; 27 | private Boolean success; 28 | private String message; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/application/entity/OrderInventory.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.entity; 2 | 3 | import com.vinsguru.common.events.inventory.InventoryStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.util.UUID; 11 | 12 | @Data 13 | @Builder 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class OrderInventory { 17 | 18 | /* 19 | We intentionally maintain 1:1 relationship 20 | */ 21 | 22 | @Id 23 | private Integer id; 24 | private UUID orderId; 25 | private UUID inventoryId; 26 | private InventoryStatus status; 27 | private String message; 28 | private Boolean success; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/application/entity/OrderInventory.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.entity; 2 | 3 | import com.vinsguru.common.events.inventory.InventoryStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.util.UUID; 11 | 12 | @Data 13 | @Builder 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class OrderInventory { 17 | 18 | /* 19 | We intentionally maintain 1:1 relationship 20 | */ 21 | 22 | @Id 23 | private Integer id; 24 | private UUID orderId; 25 | private UUID inventoryId; 26 | private InventoryStatus status; 27 | private String message; 28 | private Boolean success; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/messaging/config/OrderEventListenerConfig.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.messaging.config; 2 | 3 | import com.vinsguru.common.events.order.OrderEvent; 4 | import com.vinsguru.order.common.service.OrderEventListener; 5 | import com.vinsguru.order.messaging.publisher.OrderEventListenerImpl; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import reactor.core.publisher.Sinks; 9 | 10 | @Configuration 11 | public class OrderEventListenerConfig { 12 | 13 | @Bean 14 | public OrderEventListener orderEventListener(){ 15 | var sink = Sinks.many().unicast().onBackpressureBuffer(); 16 | var flux = sink.asFlux(); 17 | return new OrderEventListenerImpl(sink, flux); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/application/entity/PurchaseOrder.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.entity; 2 | 3 | import com.vinsguru.order.common.enums.OrderStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | 10 | import java.time.Instant; 11 | import java.util.UUID; 12 | 13 | @Data 14 | @Builder 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class PurchaseOrder { 18 | 19 | @Id 20 | private UUID orderId; 21 | private Integer customerId; 22 | private Integer productId; 23 | private Integer quantity; 24 | private Integer unitPrice; 25 | private Integer amount; 26 | private OrderStatus status; 27 | private Instant deliveryDate; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/application/repository/OrderWorkflowActionRepository.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.repository; 2 | 3 | import com.vinsguru.order.application.entity.OrderWorkflowAction; 4 | import com.vinsguru.order.common.enums.WorkflowAction; 5 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 6 | import org.springframework.stereotype.Repository; 7 | import reactor.core.publisher.Flux; 8 | import reactor.core.publisher.Mono; 9 | 10 | import java.util.UUID; 11 | 12 | @Repository 13 | public interface OrderWorkflowActionRepository extends ReactiveCrudRepository { 14 | 15 | Mono existsByOrderIdAndAction(UUID orderId, WorkflowAction action); 16 | 17 | Flux findByOrderIdOrderByCreatedAt(UUID orderId); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/messages/payment/PaymentResponse.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.messages.payment; 2 | 3 | import com.vinsguru.common.messages.Response; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | public sealed interface PaymentResponse extends Response { 9 | 10 | /* 11 | Intentionally named as Process / Processed as these are inner classes. 12 | Feel free to change if you do not like it 13 | */ 14 | 15 | @Builder 16 | record Processed(UUID orderId, 17 | UUID paymentId, 18 | Integer customerId, 19 | Integer amount) implements PaymentResponse { 20 | 21 | } 22 | 23 | @Builder 24 | record Declined(UUID orderId, 25 | String message) implements PaymentResponse { 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/messages/shipping/ShippingResponse.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.messages.shipping; 2 | 3 | import com.vinsguru.common.messages.Response; 4 | import lombok.Builder; 5 | 6 | import java.time.Instant; 7 | import java.util.UUID; 8 | 9 | public sealed interface ShippingResponse extends Response { 10 | 11 | /* 12 | Intentionally named as Schedule / Scheduled as these are inner classes. 13 | Feel free to change if you do not like it 14 | */ 15 | 16 | @Builder 17 | record Scheduled(UUID orderId, 18 | UUID shipmentId, 19 | Instant deliveryDate) implements ShippingResponse { 20 | 21 | } 22 | 23 | @Builder 24 | record Declined(UUID orderId, 25 | String message) implements ShippingResponse { 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/listener/PaymentEventListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.listener; 2 | 3 | import com.vinsguru.common.events.payment.PaymentEvent; 4 | import reactor.core.publisher.Mono; 5 | 6 | public interface PaymentEventListener extends EventListener { 7 | 8 | @Override 9 | default Mono listen(PaymentEvent event) { 10 | return switch (event) { 11 | case PaymentEvent.PaymentDeducted e -> this.handle(e); 12 | case PaymentEvent.PaymentDeclined e -> this.handle(e); 13 | case PaymentEvent.PaymentRefunded e -> this.handle(e); 14 | }; 15 | } 16 | 17 | Mono handle(PaymentEvent.PaymentDeducted event); 18 | 19 | Mono handle(PaymentEvent.PaymentDeclined event); 20 | 21 | Mono handle(PaymentEvent.PaymentRefunded event); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/messages/inventory/InventoryResponse.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.messages.inventory; 2 | 3 | import com.vinsguru.common.messages.Response; 4 | import lombok.Builder; 5 | 6 | import java.util.UUID; 7 | 8 | public sealed interface InventoryResponse extends Response { 9 | 10 | /* 11 | Intentionally named as Deduct / Deducted as these are inner classes. 12 | Feel free to change if you do not like it 13 | */ 14 | 15 | @Builder 16 | record Deducted(UUID orderId, 17 | UUID inventoryId, 18 | Integer productId, 19 | Integer quantity) implements InventoryResponse { 20 | 21 | } 22 | 23 | @Builder 24 | record Declined(UUID orderId, 25 | String message) implements InventoryResponse { 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/test/java/com/vinsguru/payment/TestDataUtil.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment; 2 | 3 | import com.vinsguru.common.messages.payment.PaymentRequest; 4 | 5 | import java.util.UUID; 6 | 7 | public class TestDataUtil { 8 | 9 | public static PaymentRequest createProcessRequest(UUID orderId, int customerId, int amount) { 10 | return PaymentRequest.Process.builder() 11 | .orderId(orderId) 12 | .customerId(customerId) 13 | .amount(amount) 14 | .build(); 15 | } 16 | 17 | public static PaymentRequest createRefundRequest(UUID orderId) { 18 | return PaymentRequest.Refund.builder() 19 | .orderId(orderId) 20 | .build(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/messaging/orchestrator/PaymentStep.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.messaging.orchestrator; 2 | 3 | import com.vinsguru.common.messages.Request; 4 | import com.vinsguru.common.messages.payment.PaymentResponse; 5 | import com.vinsguru.common.orchestrator.WorkflowStep; 6 | import org.reactivestreams.Publisher; 7 | 8 | public interface PaymentStep extends WorkflowStep { 9 | 10 | @Override 11 | default Publisher process(PaymentResponse response) { 12 | return switch (response){ 13 | case PaymentResponse.Processed r -> this.onSuccess(r); 14 | case PaymentResponse.Declined r -> this.onFailure(r); 15 | }; 16 | } 17 | 18 | Publisher onSuccess(PaymentResponse.Processed response); 19 | 20 | Publisher onFailure(PaymentResponse.Declined response); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec02/KafkaConsumer.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec02; 2 | 3 | /* 4 | goal: to demo a simple kafka consumer using java functional interfaces 5 | */ 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | import reactor.core.publisher.Flux; 12 | 13 | import java.util.function.Consumer; 14 | 15 | @Configuration 16 | public class KafkaConsumer { 17 | 18 | private static final Logger log = LoggerFactory.getLogger(KafkaConsumer.class); 19 | 20 | @Bean 21 | public Consumer> consumer() { 22 | return flux -> flux 23 | .doOnNext(s -> log.info("consumer received {}", s)) 24 | .subscribe(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec03/KafkaConsumer.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec03; 2 | 3 | /* 4 | goal: to demo a simple kafka consumer using java functional interfaces 5 | */ 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | import reactor.core.publisher.Flux; 12 | 13 | import java.util.function.Consumer; 14 | 15 | @Configuration 16 | public class KafkaConsumer { 17 | 18 | private static final Logger log = LoggerFactory.getLogger(KafkaConsumer.class); 19 | 20 | @Bean 21 | public Consumer> consumer() { 22 | return flux -> flux 23 | .doOnNext(s -> log.info("consumer received {}", s)) 24 | .subscribe(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/demo/MessageHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.demo; 2 | 3 | import java.util.Objects; 4 | import java.util.function.Function; 5 | 6 | class MessageHandlerImpl implements MessageHandler { 7 | 8 | private final I input; 9 | private O output; 10 | 11 | public MessageHandlerImpl(I input) { 12 | this.input = input; 13 | } 14 | 15 | @Override 16 | public MessageHandler onMessage(Class type, Function function) { 17 | Objects.requireNonNull(type); 18 | Objects.requireNonNull(function); 19 | if(Objects.isNull(output) && type.isInstance(input)){ 20 | this.output = function.apply((R) input); 21 | } 22 | return this; 23 | } 24 | 25 | @Override 26 | public O handle() { 27 | return this.output; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /saga-orchestrator/orchestrator-common/src/main/java/com/vinsguru/common/demo/MessageHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.demo; 2 | 3 | import java.util.Objects; 4 | import java.util.function.Function; 5 | 6 | class MessageHandlerImpl implements MessageHandler { 7 | 8 | private final I input; 9 | private O output; 10 | 11 | public MessageHandlerImpl(I input) { 12 | this.input = input; 13 | } 14 | 15 | @Override 16 | public MessageHandler onMessage(Class type, Function function) { 17 | Objects.requireNonNull(type); 18 | Objects.requireNonNull(function); 19 | if(Objects.isNull(output) && type.isInstance(input)){ 20 | this.output = function.apply((R) input); 21 | } 22 | return this; 23 | } 24 | 25 | @Override 26 | public O handle() { 27 | return this.output; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/demo/MessageHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.demo; 2 | 3 | import java.util.Objects; 4 | import java.util.function.Function; 5 | 6 | class MessageHandlerImpl implements MessageHandler { 7 | 8 | private final I input; 9 | private O output; 10 | 11 | public MessageHandlerImpl(I input) { 12 | this.input = input; 13 | } 14 | 15 | @Override 16 | public MessageHandler onMessage(Class type, Function function) { 17 | Objects.requireNonNull(type); 18 | Objects.requireNonNull(function); 19 | if(Objects.isNull(output) && type.isInstance(input)){ 20 | this.output = function.apply((R) input); 21 | } 22 | return this; 23 | } 24 | 25 | @Override 26 | public O handle() { 27 | return this.output; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/demo/MessageHandlerDemo.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.demo; 2 | 3 | import com.vinsguru.common.events.order.OrderEvent; 4 | 5 | import java.util.UUID; 6 | 7 | public class MessageHandlerDemo { 8 | 9 | 10 | public static void main(String[] args) { 11 | 12 | var event = OrderEvent.OrderCancelled.builder().orderId(UUID.randomUUID()).build(); 13 | 14 | var result = MessageHandler.create(event) 15 | .onMessage(OrderEvent.OrderCreated.class, e -> "created") 16 | .onMessage(OrderEvent.OrderCancelled.class, e -> "cancelled") 17 | .onMessage(OrderEvent.OrderCompleted.class, e -> "completed") 18 | .handle(); 19 | 20 | System.out.println(result); 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/messaging/orchestrator/ShippingStep.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.messaging.orchestrator; 2 | 3 | import com.vinsguru.common.messages.Request; 4 | import com.vinsguru.common.messages.shipping.ShippingResponse; 5 | import com.vinsguru.common.orchestrator.WorkflowStep; 6 | import org.reactivestreams.Publisher; 7 | 8 | public interface ShippingStep extends WorkflowStep { 9 | 10 | @Override 11 | default Publisher process(ShippingResponse response) { 12 | return switch (response){ 13 | case ShippingResponse.Scheduled r -> this.onSuccess(r); 14 | case ShippingResponse.Declined r -> this.onFailure(r); 15 | }; 16 | } 17 | 18 | Publisher onSuccess(ShippingResponse.Scheduled response); 19 | 20 | Publisher onFailure(ShippingResponse.Declined response); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /saga-orchestrator/order-service/src/main/java/com/vinsguru/order/messaging/orchestrator/InventoryStep.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.messaging.orchestrator; 2 | 3 | import com.vinsguru.common.messages.Request; 4 | import com.vinsguru.common.messages.inventory.InventoryResponse; 5 | import com.vinsguru.common.orchestrator.WorkflowStep; 6 | import org.reactivestreams.Publisher; 7 | 8 | public interface InventoryStep extends WorkflowStep { 9 | 10 | @Override 11 | default Publisher process(InventoryResponse response) { 12 | return switch (response){ 13 | case InventoryResponse.Deducted r -> this.onSuccess(r); 14 | case InventoryResponse.Declined r -> this.onFailure(r); 15 | }; 16 | } 17 | 18 | Publisher onSuccess(InventoryResponse.Deducted response); 19 | 20 | Publisher onFailure(InventoryResponse.Declined response); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/demo/MessageHandlerDemo.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.demo; 2 | 3 | import com.vinsguru.common.events.order.OrderEvent; 4 | 5 | import java.util.UUID; 6 | 7 | public class MessageHandlerDemo { 8 | 9 | 10 | public static void main(String[] args) { 11 | 12 | var event = OrderEvent.OrderCancelled.builder().orderId(UUID.randomUUID()).build(); 13 | 14 | var result = MessageHandler.create(event) 15 | .onMessage(OrderEvent.OrderCreated.class, e -> "created") 16 | .onMessage(OrderEvent.OrderCancelled.class, e -> "cancelled") 17 | .onMessage(OrderEvent.OrderCompleted.class, e -> "completed") 18 | .handle(); 19 | 20 | System.out.println(result); 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/processor/OrderEventProcessor.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.processor; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import com.vinsguru.common.events.order.OrderEvent; 5 | import reactor.core.publisher.Mono; 6 | 7 | public interface OrderEventProcessor extends EventProcessor { 8 | 9 | @Override 10 | default Mono process(OrderEvent event) { 11 | return switch (event){ 12 | case OrderEvent.OrderCreated e -> this.handle(e); 13 | case OrderEvent.OrderCancelled e -> this.handle(e); 14 | case OrderEvent.OrderCompleted e -> this.handle(e); 15 | }; 16 | } 17 | 18 | Mono handle(OrderEvent.OrderCreated event); 19 | 20 | Mono handle(OrderEvent.OrderCancelled event); 21 | 22 | Mono handle(OrderEvent.OrderCompleted event); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/test/java/com/vinsguru/inventory/TestDataUtil.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory; 2 | 3 | import com.vinsguru.common.messages.inventory.InventoryRequest; 4 | 5 | import java.util.UUID; 6 | 7 | public class TestDataUtil { 8 | 9 | public static InventoryRequest createDeductRequest(UUID orderId, int productId, int quantity) { 10 | return InventoryRequest.Deduct.builder() 11 | .orderId(orderId) 12 | .productId(productId) 13 | .quantity(quantity) 14 | .build(); 15 | } 16 | 17 | public static InventoryRequest createRestoreRequest(UUID orderId) { 18 | return InventoryRequest.Restore.builder() 19 | .orderId(orderId) 20 | .build(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/listener/InventoryEventListener.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.listener; 2 | 3 | import com.vinsguru.common.events.inventory.InventoryEvent; 4 | import reactor.core.publisher.Mono; 5 | 6 | public interface InventoryEventListener extends EventListener { 7 | 8 | @Override 9 | default Mono listen(InventoryEvent event) { 10 | return switch (event) { 11 | case InventoryEvent.InventoryDeducted e -> this.handle(e); 12 | case InventoryEvent.InventoryDeclined e -> this.handle(e); 13 | case InventoryEvent.InventoryRestored e -> this.handle(e); 14 | }; 15 | } 16 | 17 | Mono handle(InventoryEvent.InventoryDeducted event); 18 | 19 | Mono handle(InventoryEvent.InventoryDeclined event); 20 | 21 | Mono handle(InventoryEvent.InventoryRestored event); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /saga-choreography-outbox/choreography-common/src/main/java/com/vinsguru/common/processor/OrderEventProcessor.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.processor; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import com.vinsguru.common.events.order.OrderEvent; 5 | import reactor.core.publisher.Mono; 6 | 7 | public interface OrderEventProcessor extends EventProcessor { 8 | 9 | @Override 10 | default Mono process(OrderEvent event) { 11 | return switch (event){ 12 | case OrderEvent.OrderCreated e -> this.handle(e); 13 | case OrderEvent.OrderCancelled e -> this.handle(e); 14 | case OrderEvent.OrderCompleted e -> this.handle(e); 15 | }; 16 | } 17 | 18 | Mono handle(OrderEvent.OrderCreated event); 19 | 20 | Mono handle(OrderEvent.OrderCancelled event); 21 | 22 | Mono handle(OrderEvent.OrderCompleted event); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /saga-orchestrator/customer-payment/src/main/java/com/vinsguru/payment/messaging/processor/PaymentRequestProcessor.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.payment.messaging.processor; 2 | 3 | import com.vinsguru.common.messages.payment.PaymentRequest; 4 | import com.vinsguru.common.messages.payment.PaymentResponse; 5 | import com.vinsguru.common.processor.RequestProcessor; 6 | import reactor.core.publisher.Mono; 7 | 8 | public interface PaymentRequestProcessor extends RequestProcessor { 9 | 10 | @Override 11 | default Mono process(PaymentRequest request) { 12 | return switch (request){ 13 | case PaymentRequest.Process p -> this.handle(p); 14 | case PaymentRequest.Refund p -> this.handle(p); 15 | }; 16 | } 17 | 18 | Mono handle(PaymentRequest.Process request); 19 | 20 | Mono handle(PaymentRequest.Refund request); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/processor/PaymentEventProcessor.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.processor; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import com.vinsguru.common.events.payment.PaymentEvent; 5 | import reactor.core.publisher.Mono; 6 | 7 | public interface PaymentEventProcessor extends EventProcessor { 8 | 9 | @Override 10 | default Mono process(PaymentEvent event) { 11 | return switch (event) { 12 | case PaymentEvent.PaymentDeducted e -> this.handle(e); 13 | case PaymentEvent.PaymentDeclined e -> this.handle(e); 14 | case PaymentEvent.PaymentRefunded e -> this.handle(e); 15 | }; 16 | } 17 | 18 | Mono handle(PaymentEvent.PaymentDeducted event); 19 | 20 | Mono handle(PaymentEvent.PaymentDeclined event); 21 | 22 | Mono handle(PaymentEvent.PaymentRefunded event); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /saga-choreography/order-service/src/main/java/com/vinsguru/order/application/entity/PurchaseOrder.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.entity; 2 | 3 | import com.vinsguru.common.events.order.OrderStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | import org.springframework.data.annotation.Version; 10 | 11 | import java.time.Instant; 12 | import java.util.UUID; 13 | 14 | @Data 15 | @Builder 16 | @NoArgsConstructor 17 | @AllArgsConstructor 18 | public class PurchaseOrder { 19 | 20 | @Id 21 | private UUID orderId; 22 | private Integer customerId; 23 | private Integer productId; 24 | private Integer quantity; 25 | private Integer unitPrice; 26 | private Integer amount; 27 | private OrderStatus status; 28 | private Instant deliveryDate; 29 | 30 | @Version 31 | private Integer version; 32 | } 33 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/application/entity/PurchaseOrder.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.application.entity; 2 | 3 | import com.vinsguru.common.events.order.OrderStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.data.annotation.Id; 9 | import org.springframework.data.annotation.Version; 10 | 11 | import java.time.Instant; 12 | import java.util.UUID; 13 | 14 | @Data 15 | @Builder 16 | @NoArgsConstructor 17 | @AllArgsConstructor 18 | public class PurchaseOrder { 19 | 20 | @Id 21 | private UUID orderId; 22 | private Integer customerId; 23 | private Integer productId; 24 | private Integer quantity; 25 | private Integer unitPrice; 26 | private Integer amount; 27 | private OrderStatus status; 28 | private Instant deliveryDate; 29 | 30 | @Version 31 | private Integer version; 32 | } 33 | -------------------------------------------------------------------------------- /saga-orchestrator/inventory-service/src/main/java/com/vinsguru/inventory/messaging/processor/InventoryRequestProcessor.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.inventory.messaging.processor; 2 | 3 | import com.vinsguru.common.messages.inventory.InventoryRequest; 4 | import com.vinsguru.common.messages.inventory.InventoryResponse; 5 | import com.vinsguru.common.processor.RequestProcessor; 6 | import reactor.core.publisher.Mono; 7 | 8 | public interface InventoryRequestProcessor extends RequestProcessor { 9 | 10 | @Override 11 | default Mono process(InventoryRequest request) { 12 | return switch (request){ 13 | case InventoryRequest.Deduct r -> this.handle(r); 14 | case InventoryRequest.Restore r -> this.handle(r); 15 | }; 16 | } 17 | 18 | Mono handle(InventoryRequest.Deduct request); 19 | 20 | Mono handle(InventoryRequest.Restore request); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /saga-choreography/choreography-common/src/main/java/com/vinsguru/common/processor/InventoryEventProcessor.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.common.processor; 2 | 3 | import com.vinsguru.common.events.DomainEvent; 4 | import com.vinsguru.common.events.inventory.InventoryEvent; 5 | import reactor.core.publisher.Mono; 6 | 7 | public interface InventoryEventProcessor extends EventProcessor { 8 | 9 | @Override 10 | default Mono process(InventoryEvent event) { 11 | return switch (event) { 12 | case InventoryEvent.InventoryDeducted e -> this.handle(e); 13 | case InventoryEvent.InventoryDeclined e -> this.handle(e); 14 | case InventoryEvent.InventoryRestored e -> this.handle(e); 15 | }; 16 | } 17 | 18 | Mono handle(InventoryEvent.InventoryDeducted event); 19 | 20 | Mono handle(InventoryEvent.InventoryDeclined event); 21 | 22 | Mono handle(InventoryEvent.InventoryRestored event); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /saga-choreography-outbox/order-service/src/main/java/com/vinsguru/order/messaging/listener/ShippingEventListenerImpl.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.order.messaging.listener; 2 | 3 | import com.vinsguru.common.events.shipping.ShippingEvent; 4 | import com.vinsguru.common.listener.ShippingEventListener; 5 | import com.vinsguru.order.common.service.shipping.ShippingComponentStatusListener; 6 | import com.vinsguru.order.messaging.mapper.ShippingEventMapper; 7 | import lombok.RequiredArgsConstructor; 8 | import org.springframework.stereotype.Service; 9 | import reactor.core.publisher.Mono; 10 | 11 | @Service 12 | @RequiredArgsConstructor 13 | public class ShippingEventListenerImpl implements ShippingEventListener { 14 | 15 | private final ShippingComponentStatusListener statusListener; 16 | 17 | @Override 18 | public Mono handle(ShippingEvent.ShippingScheduled event) { 19 | var dto = ShippingEventMapper.toDto(event); 20 | return this.statusListener.onSuccess(dto); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /cloud-stream-kafka-playground/src/main/java/com/vinsguru/cloudstreamkafkaplayground/sec11/KafkaConsumer.java: -------------------------------------------------------------------------------- 1 | package com.vinsguru.cloudstreamkafkaplayground.sec11; 2 | 3 | /* 4 | goal: to demo native encoding/decoding 5 | */ 6 | 7 | import com.vinsguru.cloudstreamkafkaplayground.sec11.dto.ContactMethod; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | import org.springframework.messaging.Message; 13 | import reactor.core.publisher.Flux; 14 | 15 | import java.util.function.Consumer; 16 | 17 | @Configuration 18 | public class KafkaConsumer { 19 | 20 | private static final Logger log = LoggerFactory.getLogger(KafkaConsumer.class); 21 | 22 | @Bean 23 | public Consumer>> consumer() { 24 | return flux -> flux 25 | .doOnNext(s -> log.info("consumer received {}", s)) 26 | .subscribe(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /saga-choreography/customer-payment/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | function: 4 | definition: processor 5 | stream: 6 | default: 7 | producer: 8 | useNativeEncoding: true 9 | bindings: 10 | processor-in-0: 11 | destination: order-events 12 | group: customer-payment-group 13 | processor-out-0: 14 | destination: payment-events 15 | kafka: 16 | binder: 17 | consumer-properties: 18 | "value.deserializer": org.springframework.kafka.support.serializer.JsonDeserializer 19 | "key.deserializer": org.apache.kafka.common.serialization.StringDeserializer 20 | "auto.offset.reset": "earliest" 21 | "spring.json.trusted.packages": "com.vinsguru.common.events.*" 22 | producer-properties: 23 | "value.serializer": org.springframework.kafka.support.serializer.JsonSerializer 24 | "key.serializer": org.apache.kafka.common.serialization.StringSerializer -------------------------------------------------------------------------------- /saga-choreography/inventory-service/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | function: 4 | definition: processor 5 | stream: 6 | default: 7 | producer: 8 | useNativeEncoding: true 9 | bindings: 10 | processor-in-0: 11 | destination: order-events 12 | group: inventory-service-group 13 | processor-out-0: 14 | destination: inventory-events 15 | kafka: 16 | binder: 17 | consumer-properties: 18 | "value.deserializer": org.springframework.kafka.support.serializer.JsonDeserializer 19 | "key.deserializer": org.apache.kafka.common.serialization.StringDeserializer 20 | "auto.offset.reset": "earliest" 21 | "spring.json.trusted.packages": "com.vinsguru.common.events.*" 22 | producer-properties: 23 | "value.serializer": org.springframework.kafka.support.serializer.JsonSerializer 24 | "key.serializer": org.apache.kafka.common.serialization.StringSerializer -------------------------------------------------------------------------------- /saga-choreography/shipping-service/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | function: 4 | definition: processor 5 | stream: 6 | default: 7 | producer: 8 | useNativeEncoding: true 9 | bindings: 10 | processor-in-0: 11 | destination: order-events 12 | group: shipping-service-group 13 | processor-out-0: 14 | destination: shipping-events 15 | kafka: 16 | binder: 17 | consumer-properties: 18 | "value.deserializer": org.springframework.kafka.support.serializer.JsonDeserializer 19 | "key.deserializer": org.apache.kafka.common.serialization.StringDeserializer 20 | "auto.offset.reset": "earliest" 21 | "spring.json.trusted.packages": "com.vinsguru.common.events.*" 22 | producer-properties: 23 | "value.serializer": org.springframework.kafka.support.serializer.JsonSerializer 24 | "key.serializer": org.apache.kafka.common.serialization.StringSerializer -------------------------------------------------------------------------------- /saga-choreography-outbox/customer-payment/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | function: 4 | definition: processor 5 | stream: 6 | default: 7 | producer: 8 | useNativeEncoding: true 9 | bindings: 10 | processor-in-0: 11 | destination: order-events 12 | group: customer-payment-group 13 | processor-out-0: 14 | destination: payment-events 15 | kafka: 16 | binder: 17 | consumer-properties: 18 | "value.deserializer": org.springframework.kafka.support.serializer.JsonDeserializer 19 | "key.deserializer": org.apache.kafka.common.serialization.StringDeserializer 20 | "auto.offset.reset": "earliest" 21 | "spring.json.trusted.packages": "com.vinsguru.common.events.*" 22 | producer-properties: 23 | "value.serializer": org.springframework.kafka.support.serializer.JsonSerializer 24 | "key.serializer": org.apache.kafka.common.serialization.StringSerializer --------------------------------------------------------------------------------