Sobes.tech
Senior

There is an online store. After placing an order, it is necessary to notify CRM, warehouse, and delivery system. How would you design the interaction between systems? In which cases would you choose REST, and in which Kafka or RabbitMQ?

sobes.tech AI

Answer from AI

To notify CRM, warehouse, and delivery system after placing an order, the interaction can be designed as follows:

  1. Synchronous interaction (REST API):

    • Suitable when immediate confirmation from each system is needed.
    • For example, if order placement must be confirmed by all systems in real-time.
    • The downside is high coupling and delays if one of the systems is unavailable.
  2. Asynchronous interaction (messages via Kafka or RabbitMQ):

    • The customer publishes a "New Order" event to a queue or topic.
    • CRM, warehouse, and delivery subscribe to these events and process them independently.
    • Increases fault tolerance and scalability.
    • Allows for reprocessing and guaranteed delivery.

When to choose REST:

  • When synchronous confirmation is required.
  • When integration is simple and the number of systems is small.

When to choose Kafka/RabbitMQ:

  • When scalable, fault-tolerant, and asynchronous interaction is needed.
  • When systems can handle delayed events.
  • For integration with a large number of consumers.

Example architecture:

  • The order placement service publishes an event to Kafka.
  • CRM, warehouse, and delivery read the events and update their data.
  • For critical operations requiring confirmation, REST requests can additionally be used.

This approach ensures system flexibility, scalability, and reliability.

There is an online store. After placing an order, it… - sobes.tech