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

Offer a possibility to route commands and queries to a specific component #564

Open
OLibutzki opened this issue Dec 16, 2022 · 2 comments
Open

Comments

@OLibutzki
Copy link

OLibutzki commented Dec 16, 2022

We currently evaluate the usage of Axon Server for a multi-tenancy system. Our current idea is to use one context per tenant in order to ensure a high degree of isolation.

Nevertheless, tenants need to exchange messages (rarely). Our idea is to use one dedicated context for sending messages between tenants. For commands and queries using tags is a viable solution at first glance.

Let's reduce the problem to the usage and routing of commands:
We have three tenants: A, B and C. B and C provide a handler for the very same command.
For each tenant we have a TagsConfiguration containing the key tenant which's value is the tenant identifier (A, B or C).
If Tenant A wants to send a command to Tenant B, it puts tenant = B into the command's metadata in order to instruct the Axon Server who should be the receiver.
This works quite fine until Tenant B is (temporarily) not available. Assume only Tenant A and C are running.
Tenant A sends a command which is targeted to Tenant b (which is down). The expectation is the command cannot be sent as there is no handler. Unfortunately, Axon Server routes the command to the handler of Tenant C instead of returning an error.

To be fair, it works exactly as it's documented in the Reference Guide, but my point is that this solution is not applicable in case you want to ensure which node handles a message. Currently, the tags are just "Recommendations" in the sense of: I would prefer this command to be handled by a specific component, but if there is none it's better to handle it by some other component than throwing an error.

In the example of the Reference Guide using contry codes, this makes perfect sense, but there are scenarios where you want to ensure that a command can only be handled by the component it's targeted for.

Obviously tags are not supposed to support this use case. I am not sure if it makes sense to provide a configuration option to specify the routing strategy. Maybe tags are not the right thing to achieve my requirements. If so, what the recommended way?

Thanks for your answers.

@schananas
Copy link
Contributor

Can you reference ref guide where this is described?
To be honest I would expect if you send a messages with target context resolver pointing to specific context, that if there is no application that is connected to this context, to throw an error.

If I understudy correctly, you say that if you have two applications connected to two different contexts but if these two contexts register command handlers with same name, that Axon Server only takes into consideration command handlers name and not context when routing a message ?

@OLibutzki
Copy link
Author

If I understudy correctly, you say that if you have two applications connected to two different contexts but if these two contexts register command handlers with same name, that Axon Server only takes into consideration command handlers name and not context when routing a message ?

No, let me quote myself:

Our idea is to use one dedicated context for sending messages between tenants.

To be honest I would expect if you send a messages with target context resolver pointing to specific context, that if there is no application that is connected to this context, to throw an error.

I do not talk about the target context resolver but about using tags to control which node/tenant receives a message.

Can you reference ref guide where this is described?

Sure, you can find it here:

If there are multiple applications found with a command handler for the requested command and matching tags, Axon Server will pick one based on the provided routing key. The same will happen if there are no applications found with matching tags, so commands will not fail because there are no matching tags.

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

No branches or pull requests

2 participants