I have the following procedure
USE ServiceBrokerTest;
GO
CREATE PROCEDURE PublishNotification
@NotificationData VARCHAR(1000)
AS
DECLARE @InitDlgHandle UNIQUEIDENTIFIER
BEGIN TRAN
--Determine the Initiator Service, Target Service and the Contract
BEGIN DIALOG @InitDlgHandle
FROM SERVICE [//SBTest/NotificationsService]
TO SERVICE'//SBTest/NotificationsService'
ON CONTRACT [//SBTest/NotificationContract]
WITH ENCRYPTION=OFF;
--Send the Message
SEND ON CONVERSATION @InitDlgHandle
MESSAGE TYPE [//SBTest/NotificationMessage](@NotificationData);
COMMIT TRAN GO
Which I run with
EXECUTE PublishNotification N'<root><first type="string">lorem</first><second type="integer">0</second></root>';
Now I'd like to extract also the service to use (in the code above //SBTest/NotificationsService
) since I have multiple services. Note All services use the same NotificationContract
and NotificationMessage
.
How can I do that?
FROM
andTO
services to be dynamic rather than hard-coded in the proc? How are those determined? Seems odd to have the same service as both the initiator and target in your example. – Dan Guzman Jul 3 '18 at 12:52