Event Message

Introduction

  • Event-type messages intend to notify about an event that happened in the sender’s system like ORDER_CREATED.

Types of Events

Event with Detail

  • The body contains all the required details about the event.

  • The document can be the detail.

  • unlike with identifier type events, it requires no extra API calls. which reduces the receiver’s dependency on the sender.

  • Useful When: the sender does not store events in the database.

  • Drawback: data loss if the service dies before publishing the event.

Event with Identifier

  • The body only contains the ID.

  • Id can reference the event log or entity in the sender system.

  • After receiving the event, the receiver makes an API (RPC) call to the sender to get details.

  • Useful When:

    • The receiver is only interested in the last state of the data.

    • or the sender stores all the event logs in the database. (state change).

  • Drawback: 

    • Requires an extra API call from the receiver service.

    • Increases the receiver service dependency on the sender service.

    • What If data gets changed before the receiver reads it? Example: In a credit card system receiver gives rewards when the available balance reaches a certain threshold.

Usage

  • Useful in fire and forget type of communication.

  • Used in choreography-based saga.