1

In microservices architecture, you can follow an event driven architecture where you want to publish events, doubt it’s about size of the payload. What is a reasonable amount of data to be there? You can publish an event with a complete set of data so you don’t need clients to do additional calls.

In the other hand you can publish just minimum data so you need adicional data to get complete data set.

What are the general rules to apply here?

X.Otano
  • 2,079
  • 1
  • 22
  • 40

2 Answers2

0

There are no strict rules, just limitations.

In general there are two type of events: Domain Events and Integration Events.

Domain Events

Domain Events are emitted by an Aggregate inside the Bounded Context it belongs, but can be used as an Integration Event also.

If the event is of this type, i'd send as much data as possible about what triggered that event (think about it like an Event Store, where each event helps to reconstitute the current state of an Aggregate). Something like this:

{
    "type": "customer.last_name_updated",
    "data": {
        "lastName": "New Last Name"
    }
}

Integration Events

An Integration Event is something that happened on your system that may not translate exactly to one change in your domain.

In this case, it's very hard to have a single payload that may fulfill all clients, i'd just send the least amount of information needed for other clients.

0

It depends (tm), but there are a few patterns.

Sending the full payload is called Event-Carried State Transfer. In my experience, the events do match quite closely with the root aggregates, but sometimes you might want to have events that represent changes to a non-root aggregate. If the amount of data is worrysome, using an efficient format can reduce the size and speed up serialization (e.g. avro, protobuf, etc), and on top of that adding minimal compression can help reduce the size further.

Other types of events can be notification/commands or event souring (sending deltas).

A good source to read about other types of events is Martin Fowler article What do you mean by Event-Driven?

Augusto
  • 28,839
  • 5
  • 58
  • 88