Created
September 3, 2010 07:42
-
-
Save andreasohlund/563557 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [dbo].[SendNServiceBusMessage] | |
@TargetService NVARCHAR(200), | |
@MessageName NVARCHAR(200), | |
@MessageContent NVARCHAR(4000) | |
AS | |
BEGIN | |
-- Sending a Service Broker Message | |
DECLARE @InitDlgHandle UNIQUEIDENTIFIER; | |
DECLARE @MessageContract NVARCHAR(200); | |
DECLARE @MessageType NVARCHAR(200); | |
DECLARE @TransportMessage NVARCHAR(4000); | |
SET NOCOUNT ON | |
SET @MessageContract = 'NServiceBusTransportMessageContract'; | |
SET @MessageType = 'NServiceBusTransportMessage'; | |
BEGIN TRANSACTION; | |
BEGIN DIALOG @InitDlgHandle | |
FROM SERVICE @TargetService | |
TO SERVICE @TargetService | |
ON CONTRACT @MessageContract | |
WITH ENCRYPTION = OFF; | |
SET @TransportMessage ='<TransportMessage><Body><![CDATA[<Messages xmlns="http://tempuri.net/{Message Type including namespace here}"><'+@MessageName+'>' + | |
@MessageContent +'</'+@MessageName+'></Messages>]]></Body></TransportMessage>'; | |
SEND ON CONVERSATION @InitDlgHandle | |
MESSAGE TYPE @MessageType | |
(@TransportMessage); | |
COMMIT TRANSACTION; | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment