我正在尝试设置一个简单的消息传递设置。我正在遵循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
发布于 2012-03-06 18:06:21
查看数据库中的transmission_status
列sys.transmission_queue
:
use <testdb>;
go
select transmission_status, *
from sys.transmission_queue;
go
状态会说明问题是什么。
发布于 2012-03-06 20:14:08
经过一个非常令人沮丧的夜晚,我找到了答案。
谢谢你的帮助,雷姆斯。
我采纳了这个链接中的建议,并在Server中的"Broker:Message because“EventClass中找到了一条更具描述性的错误消息:”由于目标服务不支持服务契约,无法传递此消息。目标服务:'ActTestTgtService',服务契约:‘TestContract’。“
查看文档这里,如果您没有指定服务可以与之通信的约定,那么它只能启动消息,而不是目标。一旦我更改了下面的行,它就可以正常工作了:
create service ActTestTgtService on queue ActTestTgtQueue (TestContract);
https://dba.stackexchange.com/questions/14567
复制相似问题