Template Script: Service Broker\06 Tutorial Receiving Reply.sql

/* ************* Lesson 6: Receiving the Reply and Ending the Conversation ************* */
-- Switch to the InitiatorDB database

--Then, run it to switch context back to the DBA database where you will receive the reply message and end the conversation.

USE DBA;
GO
-- Receive the reply and end the conversation

--Then, run it to receive the reply message and end the conversation. The RECEIVE statement retrieves the reply message from the SysMonInitiatorQueue. The END CONVERSATION statement ends the initiator side of the conversation. The last SELECT statement displays the text of the reply message so that you can confirm it is the same as what was sent in the last step.

DECLARE @RecvReplyMsg NVARCHAR(100);
DECLARE @RecvReplyDlgHandle UNIQUEIDENTIFIER;

BEGIN TRANSACTION;

WAITFOR
( RECEIVE TOP(1)
    @RecvReplyDlgHandle = conversation_handle,
    @RecvReplyMsg = message_body
  FROM SysMonInitiatorQueue
), TIMEOUT 1000;

END CONVERSATION @RecvReplyDlgHandle;

-- Display recieved request.
SELECT @RecvReplyMsg AS ReceivedReplyMsg;

COMMIT TRANSACTION;
GO


SELECT * FROM sys.transmission_queue

Description for Template Script: Service Broker\06 Tutorial Receiving Reply.sql

Todo
Site Map | Printable View | © 2008 - 2012 NuRoN Consulting, INC | Powered by mojoPortal | HTML 5 | CSS | Original design by Andreas Viklund
Share This Using Popular Bookmarking Services