/*
  Setup script for server 1 database 1 for SSB sample communicating
  between two remote servers

  This script starts a dialog against the other server and then sends
  a message. 

  Any questions etc.: nielsb@develop.com

*/

--Step 1

use [rem_ssb1];
go

----start the dialog and send a message
----uncomment from here until the following go statement and run
--DECLARE @h uniqueidentifier --conversation handle
--DECLARE @msg xml; --will hold the message
--
--BEGIN DIALOG CONVERSATION @h
--FROM SERVICE rem_s1
--TO SERVICE 'rem_s2'
--ON CONTRACT [Ctract];
--
--SET @msg = '<hello00/>';
--SEND ON CONVERSATION @h
--MESSAGE TYPE [sendmsg]
--(@msg);
--
----check if the transmission_status column in sys.transmission_queue
----has any messages, if so something is not entirely correct
--DECLARE @txmsg varchar(max)
--select top(1) @txmsg = transmission_status
--from sys.transmission_queue
--if @txmsg <> ''
--  begin
--    raiserror(@txmsg, 16, 1)
--  end
--
--go

--if everything is now OK
--go now to the remote server Step 1 in the script 4_recmsg_server2_db.sql 
--to receive the message and send a message back, notice it may take a couple
--of seconds before the message appears on the queue

--Step 2
--you should now be back from the remote server where you have 
--received the message sent above. What's left is to check the queue
--here to make sure you have the message in the queue. There should
--actually be two messages in the queu, the one you sent,
--and one "End Conversation" msg.
--uncomment from here to go, and execute

--select * from q1
--go

--what's left is to end the conversation, which I leave up to you to do.

--if you want to implement activation stored procedures I suggest you have
--a look in the LocalSamples project for how to do it.