1

摘要:我确实观察到“Service Broker 协议传输已禁用或未配置”。在transmission_status队列中。似乎应该设置更多细节。或者我错过了什么?

这个问题与我之前的问题的答案直接相关。我确实遵循了使用特殊技巧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

我应该关注什么才能让它发挥作用?

4

1 回答 1

1

Service Broker 协议传输已禁用或未配置

表示端点未启动。试试ALTER ENDPOINT [<brokerendpointname>] STATE=STARTED;。如果语句成功但问题仍然存在,请检查 ERRORLOG,它应该在您运行此语句后不久显示一条错误消息,说明它为什么无法启动端点。很可能存在侦听端口冲突。

于 2012-11-02T10:17:48.057 回答