Commit 8b17a86e authored by dwentzel's avatar dwentzel

added URIs.sql

parent b8362b9a
......@@ -16,6 +16,8 @@ This folder contains the source code for my [Service Broker Demystified blog ser
`ServicesAndQueues.sql` demonstrates why we need to have both service and queue objects in Service Broker.
`URIs.sql` dispels the myth that if you use URI naming that your SQL Server will access external resources for validation.
......
/*
This is the source code for http://www.davewentzel.com/content/service-broker-demystified-must-my-sql-server-be-wired-internet
This covers some confusing aspects of URI naming of "exposed" SSB objects
*/
--basic setup
USE master
GO
CREATE DATABASE SBTest
GO
ALTER DATABASE SBTest SET NEW_BROKER
GO
USE SBTest
GO
/*
Let's create some bizarre object names and see if they work.
This is merely to prove that "non-sense" names work and SSB is not
"pinging" any of these services in the URIs.
*/
CREATE MESSAGE TYPE [dave://cannot.possibly.exist/Enterprise/Taxonomy/Services/SampleService/MessageTypes/MyMessageType]
VALIDATION = NONE;
CREATE MESSAGE TYPE [uri:Enterprise///Services\\MyOtherMessageType]
VALIDATION = NONE;
CREATE CONTRACT [//TestSSB.Enterprise.Factory.Contract] (
[dave://cannot.possibly.exist/Enterprise/Taxonomy/Services/SampleService/MessageTypes/MyMessageType]
SENT BY INITIATOR,
[uri:Enterprise///Services\\MyOtherMessageType]
SENT BY ANY);
--since Queue's are not "exposed" you really don't need a URI
CREATE QUEUE [QueueA];
CREATE QUEUE [QueueB];
CREATE QUEUE [MyCompany:SSB:Queues:QueueB];
CREATE SERVICE [\\Public\Services\MyPublicService] ON QUEUE QueueA ([//TestSSB.Enterprise.Factory.Contract]);
CREATE SERVICE [\\Private\Services\MyPrivateService] ON QUEUE QueueB ([//TestSSB.Enterprise.Factory.Contract]);
--Send some messages and see if they get "stuck"
DECLARE @h UNIQUEIDENTIFIER;
BEGIN DIALOG CONVERSATION @h
FROM SERVICE [\\Public\Services\MyPublicService]
TO SERVICE '\\Private\Services\MyPrivateService'
ON CONTRACT [//TestSSB.Enterprise.Factory.Contract]
WITH ENCRYPTION = OFF;
SEND ON CONVERSATION @h MESSAGE TYPE [dave://cannot.possibly.exist/Enterprise/Taxonomy/Services/SampleService/MessageTypes/MyMessageType] ('Message1');
SEND ON CONVERSATION @h MESSAGE TYPE [uri:Enterprise///Services\\MyOtherMessageType] ('Message2');
--did everything get to the Target?
select message_body MsgStuckInTransQ, transmission_status from sys.transmission_queue
select convert(xml,message_body) AS SendQMessages from QueueA
select convert(xml,message_body) AS RecvQMessages from QueueB
--basic cleanup
USE master;
GO
DROP DATABASE SBTest;
GO
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