Working with tenant dataThis page describes how to work with tenant-scoped data in Serialized.
To operate on data (aggregates, projections, reactions) in a multi-tenant project, the client application must indicate to Serialized which tenant is the target. The tenant ID is used as the unique identifier for the tenant and is used to route the request to the correct data store.
Some of the most important operations that are tenant-scoped are:
- Writing events
- Creating aggregates
- Updating aggregates
- Querying projections
- Canceling reactions
- Triggering reactions
- Subscribing to feeds
Making a tenant-scoped operation
To make a tenant-scoped operation, the client application must include the tenant ID in the request.
If, for example, you have a tenant with ID
13a1addc-1d81-4425-af84-50b1b960880a you can write an
order aggregate with ID
5df2e445-99bb-4e19-9d82-f2ace1b2eee6 for that tenant using the example code below.
var eventBatch = List.of(newEvent(new OrderPlaced()).build()); var request = saveRequest() .withTenantId("13a1addc-1d81-4425-af84-50b1b960880a") .withAggregateId("5df2e445-99bb-4e19-9d82-f2ace1b2eee6") .withEvents(eventBatch) .build() orderClient.save(request);
All the clients in our SDKs provide similar options for making tenant-scoped operations. See the SDK documentation for more details for each operation.
If you're using the Serialized API without our SDKs, you should include the tenant ID as a header with
Data processing in multi-tenant projects
Some data processing, such as projection processing and reaction scheduling and triggering is automatically performed in Serialized. In a multi-tenant project, this processing is performed for each tenant separately.
All definitions, such as (projection definitions and reaction definitions) are shared between tenants in the same project. This means that if you update a projection definition, all tenants in that project will be affected.