Hi all,
I have an application that needs to publish an update notification to 1 or more interested parties. The information contains sensitive data that needs to be encrypted per party so each party get's its own message.
I would like to utilise a single Direct exchange to allow me to publish a message using a routing key so that I can configure which party each message get sent to.
Each destination party may not be on the same VHost so I will be setting up shoveling.
.. bare with me as I describe my setup and findings ...
I have set up IPipe<PublishContext<T>> facade to add a routing Key to the RabbitMqSendContext *cough cough* via reflection in the Send(PublishContext<T>) method.
I created a Direct exchange with the appropriate name ( full name of contract type ) and bound 2 shovels with a different route key value each.
When I first sent the message MT created tried to create a fanout exchange with the full name of the contract, it threw an exception because the Rabbit exchange was already created with a direct exchange type.
I deleted the exchange and set it up again using a fanout and re-attached the shovels.
This time MQ successfully published the message to the exchange but each shovel got a copy of the message even though the routing key did not match 1 shovel.
It appears a fanout exchange will ignore the routing key when distributing to bound queues.
I create another direct exchange and then added another shovel between the fanout and direct exchanges, changing the first 2 shovels sources to this new exchange. Now when I publish a message to the fanout exchange it ends up in the direct exchange, finally moved onto only the correct final queue.
--- Question ---
Is there a way to set the routing key when I publish a message without using reflection? I can't find any hooks to allow me to get access to the RabbitMQ send context directly.
Can I get MT get create a direct exchange instead of a fanout, or event allow me to intercept the create process ? If not, is there an API that allows me to create a direct exchange manually when MT creates the original fanout exchange (like an observers) ?
Cheers...
Rob