Micro services. Direct vs indirect communication.

Micro services is a fun in itself. Here are tips when to use messaging over direct HTTP communication.

When to use HTTP:

  • Need to message service directly
  • Requires a confirmation about success or failure of the request/message
  • Message order matters. Need for message sequencing.
  • Need for a microservice orchestration. For example API gateway.

When to use indirect communication:

  • Requirement to broadcast message in all application. Whether message is handled does not matter.
  • Loose coupling. Enables change and development of each service separately.
  • Performance. Sender can emit messages, but receiver will process them at its own pace.
  • Requirement for no lost messages. Messages will be resent until processed by receiver.
  • Parallel processing. Multiple subscriptions from a single topic.
  • If subscribing service is offline, once it will become available it will process messages.