Activities of "manojkumar.t@shloklabs.com"

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.

  • ABP Framework version: vX.X.X
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

Our Problem

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.

What I have done?

Step 1:

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;
     }
 }

Step 2:

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 .

Step 3:

Running the projects Host, Identity service and Web. Now I am trying to create a new tenant with seperate tenant database.

Result:

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

Default tables are created,

In the Host Database, the Enterprise table is there.

Can you guys help us here?

Showing 1 to 2 of 2 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11