摘要:我确实观察到" Service Broker协议传输已禁用或未配置。"在队列的transmission_status
中。似乎应该设置更多细节。或者我错过了什么?
该问题与the answer to my earlier question直接相关。
我确实遵循了使用特殊技巧GRANT CONNECT ON ENDPOINT::[<brokerendpointname>] TO [public]
的建议,以简化受信任本地网络中的插件配置类型:
create message type...
create contract ...
create queue ...
create service [tcp://MACHINE3:4022/Satellite]
on ...
([...]);
grant send on service::[tcp://MACHINE3:4022/Satellite] to [public];
create route transport with address = 'TRANSPORT';
对于细节可能起作用的情况,这里是真实代码的摘录:
USE [MySatelliteDB];
CREATE MESSAGE TYPE [//x/y/RequestMessage]
VALIDATION = WELL_FORMED_XML;
CREATE MESSAGE TYPE [//x/y/ReplyMessage]
VALIDATION = WELL_FORMED_XML;
CREATE CONTRACT [//x/y/SimpleContract]
([//x/y/RequestMessage] SENT BY INITIATOR,
[//x/y/ReplyMessage] SENT BY TARGET);
CREATE QUEUE GenericQueue;
CREATE SERVICE [tcp://192.168.4.120:4022/GenericService]
ON QUEUE GenericQueue ([//x/y/SimpleContract]);
GRANT SEND ON SERVICE::[tcp://192.168.4.120:4022/GenericService] TO [public];
CREATE ROUTE transport WITH ADDRESS = 'TRANSPORT';
除了数据库名称和IP地址(在这种情况下以158结尾)之外,中央计算机使用相同的名称。然后我尝试发送显式虚拟消息......
DECLARE @InitDlgHandle UNIQUEIDENTIFIER;
DECLARE @RequestMsg NVARCHAR(100);
BEGIN TRANSACTION;
BEGIN DIALOG @InitDlgHandle
FROM SERVICE [tcp://192.168.4.120:4022/GenericService]
TO SERVICE N'tcp://192.168.4.158:4022/GenericService'
ON CONTRACT [//x/y/SimpleContract]
WITH
ENCRYPTION = OFF;
SELECT @RequestMsg = N'<RequestMsg>Message for Target service.</RequestMsg>';
SEND ON CONVERSATION @InitDlgHandle
MESSAGE TYPE [//x/y/RequestMessage]
(@RequestMsg);
SELECT @RequestMsg AS SentRequestMsg;
COMMIT TRANSACTION;
GO
显示
SentRequestMsg
<RequestMsg>Message for Target service.</RequestMsg>
......显然是最后一次选择的结果。这样我猜COMMIT TRANSACTION
成功了。 (未观察到错误消息。)
然后我打开了其他SQL服务器的SSMS窗口,并尝试接收...
DECLARE @RecvReqDlgHandle UNIQUEIDENTIFIER;
DECLARE @RecvReqMsg NVARCHAR(100);
DECLARE @RecvReqMsgName sysname;
BEGIN TRANSACTION;
WAITFOR
( RECEIVE TOP(1)
@RecvReqDlgHandle = conversation_handle,
@RecvReqMsg = message_body,
@RecvReqMsgName = message_type_name
FROM GenericQueue
), TIMEOUT 1000;
SELECT @RecvReqMsg AS ReceivedRequestMsg;
IF @RecvReqMsgName =
N'//x/y/RequestMessage'
BEGIN
DECLARE @ReplyMsg NVARCHAR(100);
SELECT @ReplyMsg =
N'<ReplyMsg>Message for Initiator service.</ReplyMsg>';
SEND ON CONVERSATION @RecvReqDlgHandle
MESSAGE TYPE
[//x/y/ReplyMessage] (@ReplyMsg);
END CONVERSATION @RecvReqDlgHandle;
END
SELECT @ReplyMsg AS SentReplyMsg;
COMMIT TRANSACTION;
GO
显示两个带有意外值的结果
ReceivedRequestMsg
NULL
---------------------------------------------
SentReplyMsg
NULL
未观察到任何错误消息。
运行脚本时......
USE [MySatelliteDB];
SELECT * FROM GenericQueue WITH (NOLOCK);
SELECT * FROM sys.transmission_queue;
我可以看到某些东西不能正常工作(是一行,手动包装)
conversation_handle to_service_name
1A227CA7-6F24-E211-B1EC-004063F5CE90 tcp://192.168.4.158:4022/GenericService
------------------------------------------------------------------------------...
to_broker_instance from_service_name
<empty> tcp://192.168.4.120:4022/GenericService
------------------------------------------------------------------------------...
service_contract_name enqueue_time
//x/y/SimpleContract 2012-11-01 22:01:15.440
------------------------------------------------------------------------------...
message_sequence_number message_type_name
0 /x/y/RequestMessage
------------------------------------------------------------------------------...
is_conversation_error is_end_of_dialog message_body
0 0 0x3C0052006...snip...3E00
------------------------------------------------------------------------------...
transmission_status priority
The Service Broker protocol transport is disabled or not configured. 5
我应该关注什么才能让它发挥作用?
答案 0 :(得分:1)
禁用或未配置Service Broker协议传输
表示端点未启动。试试ALTER ENDPOINT [<brokerendpointname>] STATE=STARTED;
。如果语句成功但问题仍然存在,请检查ERRORLOG,它应该在您运行此语句后不久显示错误消息,说明无法启动端点的原因。最有可能是侦听端口冲突。