Creating tenants
This page describes how to create tenants in Serialized.Creating a tenant
Each tenant has an isolated data store. This data store includes all data that you store in Serialized:
- Aggregates
- Projections
- Reactions
Before you can store data in a multi-tenant project you must create the tenant explicitly. Each tenant has a unique ID and a (optional) reference which can be used either as a human-readable identifier (such as a customer name) or the ID of the tenant in a different system.
When the tenant is created via the API a data store for the tenant is created. You will also be able to view the tenant data in the Console.
Below is an example of how to create a tenant with ID 13a1addc-1d81-4425-af84-50b1b960880a
using our SDKs. Note that
the project that the client is configured for must have multi-tenancy enabled.
var tenantClient = tenantClient(config).build(); tenantClient.addTenant(Tenant.newTenant(UUID.fromString("13a1addc-1d81-4425-af84-50b1b960880a")).build());
Adding a reference
Each tenant has an optional reference. You can add a reference to a tenant when creating the tenant or later by updating the tenant information. Since the reference is optional and not used by Serialized, updating it does not affect the operations in any way.
Below is an example of how to create a tenant with ID 13a1addc-1d81-4425-af84-50b1b960880a
and a reference
of customer-1
using our SDKs.
var tenantClient = tenantClient(config).build();UUID tenantId = UUID.fromString("13a1addc-1d81-4425-af84-50b1b960880a");Tenant tenant = Tenant.newTenant(tenantId).reference("customer-1").build();tenantClient.addTenant(tenant);
Tenant data processing
After a tenant has been created, you can start storing events for the tenant. The events will be stored in the tenant's isolated data store. If you have definitions defined in the project, events that are stored for the tenant will be processed according to the definitions immediately. Any data that is the result of the processing of these events (such as projections and reactions) will also be stored in the tenant's isolated data store.