-- bld 5 query
USE [Equipment]
--setuser 'ParkerStreet'

setuser

CREATE 
--ALTER
PROC SendMessage(@msg XML)
AS
BEGIN TRAN
DECLARE @conv UNIQUEIDENTIFIER
BEGIN DIALOG CONVERSATION @conv
FROM SERVICE [Inspection Team]
TO SERVICE 'Central Maintenance'
--ON CONTRACT Con1
WITH ENCRYPTION = OFF;
SELECT @conv;
SEND ON CONVERSATION @conv
--MESSAGE TYPE MsgT1
(@msg)
COMMIT TRAN

--38C7440B-A048-DA11-BF8A-000C290CBD29
--98E21B1C-A148-DA11-BF8A-000C290CBD29
select * from sys.transmission_queue


select conversation_handle from sys.transmission_queue AS T
JOIN sys.routes AS R
ON T.to_service_name = R.remote_service_name




select * from sys.routes
select * from sys.endpoints
select * from sys.transmission_queue

--ALTER DATABASE [Equipment]  SET NEW_BROKER

select * from sys.dm_broker_connections

select * from [Inspection Queue]
select CAST(Message_body AS XML) from [Inspection Queue]

setuser 'Inspector'
EXEC SendMessage N'<test123/>'
setuser

GRANT EXECUTE ON SendMessage TO Inspector


ALTER DATABASE Equipment SET NEW_BROKER


select CAST(message_body as XML) from [Inspection Queue]

select * from sys.sysusers


-- Connection handshake failed. The certificate used by the peer is invalid due to the following reason: Certificate not found. State 89.
-- Connection handshake failed. The certificate used by the peer is invalid due to the following reason: Certificate not found. State 89.
--Connection handshake failed. The certificate used by the peer is invalid due to the following reason: Certificate not found. State 89.
--An error occurred while receiving data: '64(The specified network name is no longer available.)'.
--An error occurred while receiving data: '10054(An existing connection was forcibly closed by the remote host.)'.
