Commit 177f837a authored by dwentzel's avatar dwentzel

edit closed conversations demo

parent 99147ece
/*
This is the source code for .
This demos how a conversation replay attack is thwarted using SSB's native features.
*/
--basic setup
CREATE DATABASE SBTest;
GO
ALTER DATABASE SBTest SET NEW_BROKER;
GO
USE SBTest
GO
--basic cleanup
USE master;
GO
DROP DATABASE SBTest;
GO
/*
This is the source code for .
This is the source code for http://www.davewentzel.com/content/service-broker-demystified-closed-conversations.
This covers some interesting anomalies with CLOSED conversations.
......@@ -13,10 +13,73 @@ GO
USE SBTest
GO
CREATE QUEUE TestQ;
CREATE SERVICE TestSvc ON QUEUE TestQ ([DEFAULT]);
CREATE QUEUE ReceiveQ;
CREATE SERVICE ReceiveSvc ON QUEUE ReceiveQ([DEFAULT]);
--submit a rudimentary message
BEGIN TRANSACTION
DECLARE @h UNIQUEIDENTIFIER;
BEGIN DIALOG @h
FROM SERVICE [TestSvc]
TO SERVICE 'ReceiveSvc', 'CURRENT DATABASE'
WITH ENCRYPTION = OFF;
SEND ON CONVERSATION @h ('Some message');
COMMIT;
GO
--notice I have two conversation endpoints, one for the sender
--and for the receiver with the same conversation_handle
select conversation_handle, is_initiator,state_desc, far_service
from sys.conversation_endpoints
--have the receiver acknowledge it
BEGIN TRAN
DECLARE @rh UNIQUEIDENTIFIER;
WAITFOR(
RECEIVE
TOP(1) @rh = conversation_handle
FROM ReceiveQ
), TIMEOUT 2000 ;
--at this point we would process the message and ack it
--somehow. I prefer to keep things simple and merely
--END CONVERSATION. Your specific requirements may
--require ongoing dialog communications, ie,
--SEND ON CONVERSATION @rh ('Some response here');
END CONVERSATION @rh;
COMMIT
GO
--still two conversation endpoints, but note the receiver
--has disconnected
select conversation_handle, is_initiator,state_desc, far_service
from sys.conversation_endpoints
--finally, have the sender end the conversation on its side
BEGIN TRAN
DECLARE @endh UNIQUEIDENTIFIER;
WAITFOR(
RECEIVE
TOP(1) @endh = conversation_handle
FROM TestQ
), TIMEOUT 2000 ;
END CONVERSATION @endh;
COMMIT
GO
--still two conversation endpoints, but note the receiver
--has disconnected
select GETUTCDATE()
select conversation_handle, is_initiator,state_desc, far_service , security_timestamp
from sys.conversation_endpoints
--basic cleanup
......
......@@ -8,8 +8,6 @@ This folder contains the source code for my [Service Broker Demystified blog ser
`contracts_and_message_types.sql` covers why contracts and message types are optional, yet really important.
`ConversationReplayAttacks.sql` demos how a SSB replay attack occurs and how SSB natively thwarts it.
`Conversations.sql` covers some interesting anomalies with CLOSED conversations.
`default_contract.sql` and `default_contract2.sql` covers why [DEFAULT] contract is not the default contract for a service
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment