How to publish two messages of the same type to different worker instances based on the message content without using Send and RequestAddress?
My scenario is:
I am using Azure ServiceBus and Azure StorageTables.
I am running two different instances of the same worker service workera and workerb. I need workera and workerb to both consume messages of type Command based on the value of Command.WorkerPrefix.
the Command type looks like:
{
WorkerPrefix = "a"
}
Additional constraints:
For all the messaging entities that the worker service will consume I want to add a distinct prefix whether its workera or workerb so I use the code cfg.SetEndpointNameFormatter(KebabCaseEndpointNameFormatter(args.[0], false)) where args.[0] is either "a" or "b"
Right now I only have one consumer defined that consumes a message of type Command
This gives me a topology like:
Queues:
- a-command
- b-command
Topics:
- command
Subscriptions:
- a-command -> fwd a-command
- b-command -> fwd b-command
Ideally the topology would instead be:
Queues:
- a-command
- b-command
Topics:
- a-command
Subscriptions:
- a-command -> fwd a-command
- b-command
Subscriptions:
- b-command -> fwd b-command
The reason for this desired topology is such that workera would not have permissions to create subscriptions on workerb's topics and vice versa. If this is not possible I can probably resolve the permissioning issue at deployment time by creating the topology before the services start running, but would prefer the topology above.
Now from an orchestrator, either a Saga or a Future, I want to Publish two Requests of type Command. One destined for workera and one destined for workerb.
Is there anyway to configure a IPublishEndpoint based on the content of the message such that the publisher can inspect the message see that WorkerPrefix is "a" then publish to the a-command topic?