Hi, We have been thinking of having an infrastructure, in which any of the microservice needs to be dedicted to serve a single tenant.
For understanding, I had attached a image for the reference.
In this above image, you can see that,
We have 3 tenants, A,B & C - with seperate Databases respectively.
And you can also see that we have 1 microservice (Product) running on 2 instances (pointing different port).
Now, In our business case, We have a tenant in Enterprise edition, who asks for a dedicated Microservice, Where the tenant need not to have the latency because of other tenant sharing the same microservice. So they are asking for a dedicated instance of the microservice only serving to them.
This is the case, I had tried to replicate on the image above.
Now, I would like to know from ABP team, That ABP already have this capability? or Is there any work arounds for that? or I would like to have the ABP teams suggestions for this problem?.
Thanks.
I am trying to seed some default records into the tenant side database, whenever a new tenant is created.
Normally, while creating a tenant editionDataSeeder in the SaasDataSeeder is triggered. I would like to create such a functionality to create set of DB with some default entries.
Created a new entity with FullAuditedAggregateRoot and IMulititenant
public class Enterprise : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
public virtual Guid? TenantId { get; set; }
[NotNull]
public virtual string EnterpriseName { get; set; }
[NotNull]
public virtual string EnterpriseHostName { get; set; }
[NotNull]
public virtual string EnterpriseEmail { get; set; }
public Enterprise(Guid id, string enterpriseName, string enterpriseHostName, string enterpriseEmail, Guid? tenantId)
{
Id = id;
Check.NotNull(enterpriseName, nameof(enterpriseName));
Check.Length(enterpriseName, nameof(enterpriseName), EnterpriseConsts.EnterpriseNameMaxLength, EnterpriseConsts.EnterpriseNameMinLength);
Check.NotNull(enterpriseHostName, nameof(enterpriseHostName));
Check.Length(enterpriseHostName, nameof(enterpriseHostName), EnterpriseConsts.EnterpriseHostNameMaxLength, EnterpriseConsts.EnterpriseHostNameMinLength);
Check.NotNull(enterpriseEmail, nameof(enterpriseEmail));
Check.Length(enterpriseEmail, nameof(enterpriseEmail), EnterpriseConsts.EnterpriseEmailMaxLength, EnterpriseConsts.EnterpriseEmailMinLength);
EnterpriseName = enterpriseName;
EnterpriseHostName = enterpriseHostName;
EnterpriseEmail = enterpriseEmail;
TenantId = tenantId;
}
}
Created a Dataseeder class for some default entries.
public class EnterpriseDataSeedContributor : IDataSeedContributor, ITransientDependency
{
private readonly IEnterpriseRepository _enterpriseRepository;
private readonly IGuidGenerator _guidGenerator;
private readonly ICurrentTenant _currentTenant;
public EnterpriseDataSeedContributor(
IEnterpriseRepository enterpriseRepository,
IGuidGenerator guidGenerator,
ICurrentTenant currentTenant
)
{
_enterpriseRepository = enterpriseRepository;
_guidGenerator = guidGenerator;
_currentTenant = currentTenant;
}
[UnitOfWork]
public virtual async Task SeedAsync(DataSeedContext context)
{
using (_currentTenant.Change(context?.TenantId))
{
if (await _enterpriseRepository.GetCountAsync() > 0)
{
return;
}
var enterprise = new Enterprise(
id: _guidGenerator.Create(),
enterpriseName: "Initial Seed",
enterpriseHostName: "initial",
enterpriseEmail: "initailSeed@gmail.com",
tenantId: context?.TenantId
);
await _enterpriseRepository.InsertAsync(enterprise);
}
}
}
I believe that this unit of work will automatically get executed from TenantDatabaseMigrationHandler inside the Domain/Data .
Running the projects Host, Identity service and Web. Now I am trying to create a new tenant with seperate tenant database.
Tenant database is created with all the default tables, but the table respective to the above entity (Enterprise) is not created.
I had followed this article, https://docs.abp.io/en/abp/latest/Multi-Tenancy#imultitenant
In the Host Database, the Enterprise table is there.
Can you guys help us here?