Sak*_*o73 3 sql-server-2008 sql-server
我正在尝试设置一个简单的 SQL Server Service Broker 消息设置。我正在关注 MS 教程,但无法使以下代码正常工作。一切运行正常,但消息没有出现在队列中。任何人都可以找出问题所在。
谢谢你的帮助。
-- This query returns "1"
SELECT
Is_Broker_Enabled
FROM Sys.Databases
WHERE Name = 'ActivationTest2';
GO
-- Create the message types.
CREATE MESSAGE TYPE TestRequestMessage VALIDATION = WELL_FORMED_XML;
CREATE MESSAGE TYPE TestReplyMessage VALIDATION = WELL_FORMED_XML;
-- Create the contract.
CREATE CONTRACT TestContract (
TestRequestMessage SENT BY INITIATOR,
TestReplyMessage SENT BY TARGET) ;
-- Create the target queue and service.
CREATE QUEUE ActTestTgtQueue;
CREATE SERVICE ActTestTgtService ON QUEUE ActTestTgtQueue;
-- Create the initiator queue and service.
CREATE QUEUE ActTestInitQueue;
CREATE SERVICE ActTestInitService ON QUEUE ActTestInitQueue;
GO
-- Start a conversation, send the request message.
DECLARE
@initdlghandle uniqueidentifier,
@requestmsg nvarchar (100) ;
BEGIN TRANSACTION;
BEGIN DIALOG @initdlghandle
FROM SERVICE ActTestInitService
TO SERVICE 'ActTestTgtService'
ON CONTRACT TestContract
WITH ENCRYPTION = OFF;
SET @requestmsg = N'<RequestMsg>Message for tgt service</RequestMsg>';
-- This returns a GUID and the message text above.
SELECT
@requestmsg AS Sentrequestmsg
, @initdlghandle AS Handle;
SEND ON CONVERSATION @initdlghandle
MESSAGE TYPE TestRequestMessage (@requestmsg) ;
COMMIT TRANSACTION;
GO
-- Check the queue for messages.
-- THIS RETURNS ZERO ROWS.
SELECT
*
FROM ActTestTgtQueue;
GO
Run Code Online (Sandbox Code Playgroud)
查看数据库中的transmission_status列sys.transmission_queue:
use <testdb>;
go
select transmission_status, *
from sys.transmission_queue;
go
Run Code Online (Sandbox Code Playgroud)
状态将说明问题是什么。
| 归档时间: |
|
| 查看次数: |
14237 次 |
| 最近记录: |