Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support database isolated multi-tenancy #699

Open
mertyildiz41 opened this issue Oct 28, 2020 · 10 comments
Open

Support database isolated multi-tenancy #699

mertyildiz41 opened this issue Oct 28, 2020 · 10 comments

Comments

@mertyildiz41
Copy link

Hi,
When using microservice architecture, event process at the same time with different tenant, may better to archive this information on the header and using multi-tenancy database architecture.

Is it possible to open a new branch for this feature?

@yang-xiaodong
Copy link
Member

Hello,

I am not sure what kind of multi-tenant architecture is used in your project. In our practice, the tenant id is stored in the message header, and then the consumer retrieves it from the header.

You can think that message-based and HTTP-based(request-response) have familiar processing methods.

Let me know what you think?

@mertyildiz41
Copy link
Author

Hello yang-xiaodong,

I sending event for calculation and after whole calculation done i gonna process calculation result, I don't know is it right way but i thinking to follow Received table to event is Success. But multi-tenant is block me is that way. i can't select Received table without tenant id and also hard to where clause inside of content json. Do you have any idea how i know whole events is done after i sending million events. I'll be pleased :)

@yang-xiaodong
Copy link
Member

I got it, it seems that querying by tenant-id in json is indeed not a good idea, we will consider support for multi-tenancy.

At present, I think you can create a mapping table, map the Id of the Received table to the tenant Id, and then use the sql join query to get the data you want.

You can get Received table Id using the following code:

[CapSubscribe("xxxxx")]
public void Subscriber2(Person p, [FromCap]CapHeader header)
{
   // received table id
    var id = header[Headers.MessageId]; 
}

@ztzsws1
Copy link

ztzsws1 commented Nov 17, 2020

Hi @yang-xiaodong ,
I read the above discussion and it seems that @mertyildiz41 his multi-tenant architecture is based on table or row isolation.
So you plan to add tenantId column in publish and receive table for support multi-tenancy?
Do you plan to support a multi-tenant architecture with database isolation?
Thanks,

@yang-xiaodong
Copy link
Member

Hello @ztzsws1 ,

The currently architecture unable to support a multi-tenant system with database isolation.

If you have any ideas, please feel free to drop them here

@colinin
Copy link
Contributor

colinin commented Mar 23, 2021

I think it's possible to store the identity of a tenant in Message.Headers and use static fields to allow users to change the identity name of a tenant

@mertyildiz41
Copy link
Author

I think static fields, not the correct way. Bcz with every message delivery with the different tenants. I actually taking tenant info from the user credential. Better to run out from authentication to message header.

@matengo
Copy link

matengo commented May 7, 2021

With our previous messaging solution we attach tennant info to each outgoing message, and then on the reciever side, we have a pipeline before the message end up in the recever function, where we take the tennant info from the message and create a new scope (using (var scope = _serviceProvider.CreateScope()){}) get a scoped tennant info class from the DI container, set tennant info to the class, and then call the reciever function.. Then in the reciever function, and everywhere in the scope of this message we have an injectable tennant info class... Would something like that be possible?

@teomane
Copy link
Contributor

teomane commented Dec 8, 2021

The article "Using CAP library in a multi-tenant application via SubscribeFilter" may give an idea about multitenancy

@yang-xiaodong yang-xiaodong changed the title Support Multi-Tenancy Support database isolated multi-tenancy Aug 17, 2023
@witskeeper
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants