Hi All,
While processing command in a message handler, I have to send commands to multiple ASB endpoints.
Say I am processing a request and I have to create CommandA and CommandB. Need to send CommandA to ASB-1 and CommandB to ASB-2.
Can you please help me if there is any sample/POC available?
Thanks
-Kesav
@chennakesavulu.p,
setting that up is a two steps process. First, you need to configure the transport routing when configuring the endpoint:
var routing = endpointConfiguration.UseTransport(new AzureServiceBusTransport());
routing.RouteToEndpoint(
messageType: typeof(CommandA),
destination: "ASB-1");
routing.RouteToEndpoint(
messageType: typeof(CommandB),
destination: "ASB-2");
Once that’s done, in the message handler:
public async Task Handle(IncomingMessage message, IMessageHandlerContext context)
{
var cmdA = new CommandA
{
//set properties as needed
};
await context.Send(cmdA);
var cmdB = new CommandB
{
//set properties as needed
};
await context.Send(cmdB);
}
Let me know if that helps
.m