The mysteries of software development and networking... RSS 2.0



 Wednesday, November 15, 2006

Here is the sample SQL script to create a simple queue in SQL Server 2005:


-- Needed to send messages!
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'MyPassword';
GO

-- All messages need to be typed.
CREATE MESSAGE TYPE
[//DEVELOP-ONE.COM/schemas/Test/XmlMessage]
VALIDATION = VALID_XML;
GO

-- Create a contract
CREATE CONTRACT
[//DEVELOP-ONE.COM/schemas/Test/BasicXmlQueueContract]
( [//DEVELOP-ONE.COM/schemas/Test/XmlMessage]
SENT BY ANY
) ;
GO

-- Create a queue which is turned on and which retains
-- messages in the database.
CREATE QUEUE BasicXmlQueue
WITH STATUS=ON, RETENTION=ON;
GO

-- Create the service needed to send messages.
CREATE SERVICE [//DEVELOP-ONE.COM/Sql/Services/Test/BasicXmlService]
ON QUEUE [dbo].[BasicXmlQueue]
([//DEVELOP-ONE.COM/schemas/Test/BasicXmlQueueContract]) ;
GO

-- Create a stored procedure to send a message
CREATE PROCEDURE SendXMLMessage
@MessageContent XML
AS
BEGIN

DECLARE @dialog_handle UNIQUEIDENTIFIER;

BEGIN DIALOG CONVERSATION @dialog_handle
FROM SERVICE [//DEVELOP-ONE.COM/Sql/Services/Test/BasicXmlService]
TO SERVICE '//DEVELOP-ONE.COM/Sql/Services/Test/BasicXmlService'
ON CONTRACT [//DEVELOP-ONE.COM/schemas/Test/BasicXmlQueueContract] ;


SEND ON CONVERSATION @dialog_handle
MESSAGE TYPE [//DEVELOP-ONE.COM/schemas/Test/XmlMessage]
(@MessageContent) ;

-- return dialog_handle
SELECT @dialog_handle ;

END ;
GO

CREATE PROCEDURE ReceiveXMLMessage
@Timeout int
AS
BEGIN
DECLARE @tempTable as TABLE(
conversation_handle UNIQUEIDENTIFIER,
message_body XML) ;

WAITFOR( RECEIVE TOP (1)
conversation_handle,
message_body
FROM BasicXmlQueue
INTO @tempTable ), TIMEOUT @Timeout;

DECLARE @conversation_handle as UNIQUEIDENTIFIER;

SELECT TOP (1) @conversation_handle = conversation_handle
FROM @tempTable ;

IF ( @conversation_handle IS NOT NULL )
BEGIN
-- remove message from queue without sending an End Of Conversation message.
END CONVERSATION @conversation_handle WITH CLEANUP ;
END

-- return the message body
select message_body from @tempTable;

END ;
GO

Wednesday, November 15, 2006 9:31:38 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
SQL
Tracked by:
"http://blastpr.com/wiki/js/pages/wellbutrin/index.html" (http://blastpr.com/wik... [Pingback]
"http://blastpr.com/wiki/js/pages/claritin/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://blastpr.com/wiki/js/pages/rainbow-brite/index.html" (http://blastpr.com/... [Pingback]
"http://blastpr.com/wiki/js/pages/celebrex/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://morningside.edu/mics/_notes/pages/cymbalta/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/celexa/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/cialis/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/nexium/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/wellbutrin/index.html" (http://morning... [Pingback]
"http://morningside.edu/mics/_notes/pages/prilosec/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/coumadin/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://morningside.edu/mics/_notes/pages/lipitor/index.html" (http://morningsid... [Pingback]
"http://morningside.edu/mics/_notes/pages/nexium/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/lipitor/index.html" (http://blastpr.com/wiki/j... [Pingback]
"http://blastpr.com/wiki/js/pages/ultram/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/coumadin/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/prozac/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/claritin/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/clomid/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/synthroid/index.html" (http://mornings... [Pingback]
"http://morningside.edu/mics/_notes/pages/accutane/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/soma/index.html" (http://blastpr.com/wiki/js/p... [Pingback]
"http://morningside.edu/mics/_notes/pages/lexapro/index.html" (http://morningsid... [Pingback]
"http://blastpr.com/wiki/js/pages/viagra/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/melatonin/index.html" (http://mornings... [Pingback]
"http://blastpr.com/wiki/js/pages/cialis/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/ultram/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/celexa/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/cymbalta/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://morningside.edu/mics/_notes/pages/rainbow-brite/index.html" (http://morn... [Pingback]
"http://morningside.edu/mics/_notes/pages/celebrex/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/prozac/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/effexor/index.html" (http://blastpr.com/wiki/j... [Pingback]
"http://blastpr.com/wiki/js/pages/paxil/index.html" (http://blastpr.com/wiki/js/... [Pingback]
Comments are closed.
About
This blog is run by Mark Blomsma.
© Copyright 2008
Develop-One
Sign In
Statistics
Total Posts: 309
This Year: 53
This Month: 6
This Week: 0
Comments: 36
All Content © 2008, Develop-One
DasBlog theme 'Business' created by Christoph De Baene (delarou)