views:

79

answers:

1

Hi there,

could I send messages from one service to multiple service using service brokers?

Something like

BEGIN DIALOG CONVERSATION @dialog_handle
   FROM SERVICE [SERVICE1]
   TO SERVICE 'SERVICE2',**'SERVICE3'**
   ON CONTRACT [MainContract] 

Looking at the syntax, I do not think we could do this. What's the alternative?

Thanks and Regards

DEE

+2  A: 

There is no publish-subscribe nor multicast built in into Service Broker. To send a message to multiple services you have to explicitly send it to each destination an o a separate dialog.

The typical solution is to send only one message from the application to a service that acts like a distributor. The distributor service receives this message and sends a copy of it to each interested service (Service2, Service3 etc). This way the application doesn't need to know upfront how many services it needs to send the message to, it just sends it to the distributor service.

Remus Rusanu
Remus,Thanks for your reply . i have a requirement where in i have to wait for all the Target to return (SERVICE1,SERVICE2..). what do you suggest ? should i have a table with all the conversations,messages, initiators,Targets and then update the table when all the messages come from Targets. Thanks for your follow up
DEE
Basically this is like making Async queue's synchronous
DEE
if not Service broker whats the other way to do this, i have to send messages from on DB instance to another and wait for the response.
DEE