1

If i have a generic service, like an email service which sends emails based on events from other services, which one of these approaches would be best:

  1. Email service listens to multiple queues/specific events and sends emails once those events trigger. For example email service listens to users_queue and sends a welcome email on user_created event.

  2. Have a generic email queue to which multiple services can emit a generic send_email event. Another note on this approach: what if other services, apart from the email service, want to listen to events from this service? Should i emit two events, one to the email queue and one to a queue specific for this service and have those other services implement the first approach?

Luka Mikavica
  • 118
  • 2
  • 7

1 Answers1

0

If I understand you question correctly, you are asking whether you should adopt an Orchestration or Choreography based approach:

  • Service Orchestration refers to an imperative coordination style, here imperative coordination referring to a sequence of instructions with explicit control and data flow.
  • Service Choreography refers to a declarative coordination style, here declarative coordination referring to a set of instructions with implicit control and data flow.

Alternative #1 details a Choreography based approach, the Email service reacts to a set of Events types on a set of queues, here one event type user_created on the queue users_queue

Alternative #2 details an Orchestration based approach, the Email service reacts to one Command type on one queue, here the command type send_email on the queue email_queue

When choosing an approach, consider this:

Email service require a set of input arguments like recipient address, subject line, email template, and template data.

So if you choose a Choreography based approach, every event that the Email service reacts to must provide (information to retrieve) the required arguments - In fact every event must provide all (information to retrieve) the required arguments for all services that react to the event.

To your last question if you should emit the same event to multiple queues:

Consider emitting the event once and have the eventing middleware take care of managing subscriptions and/or event routing

dtornow
  • 131
  • 1
  • 5