Service Broker教程 - 一台计算机上的两个SQL Server实例。怎么路线?

时间:2012-07-18 11:27:33

标签: service-broker

我正在关注MSDN的Completing a Conversation Between Instances教程。 Lesson 2: Creating the Initiator Database(最后)显示了如何在启动器站点创建路由(缩短):

...
USE InstInitiatorDB;
CREATE ROUTE InstTargetRoute
WITH SERVICE_NAME =
       N'//TgtDB/2InstSample/TargetService',
     ADDRESS = N'TCP://MyTargetComputer:4022';

...

USE msdb;
CREATE ROUTE InstInitiatorRoute
WITH SERVICE_NAME =
       N'//InstDB/2InstSample/InitiatorService',
     ADDRESS = N'LOCAL'

并且Lesson 3: Completing the Target Conversation Objects在目标实例上执行相同的操作:

USE InstTargetDB;
CREATE ROUTE InstInitiatorRoute
WITH SERVICE_NAME =
       N'//InstDB/2InstSample/InitiatorService',
     ADDRESS = N'TCP://MyInitiatorComputer:4022';

...

USE msdb
CREATE ROUTE InstTargetRoute
WITH SERVICE_NAME =
        N'//TgtDB/2InstSample/TargetService',
     ADDRESS = N'LOCAL';

但是,本教程假定SQL Server实例在不同的硬件上运行。如果两个SQL Server实例在同一台机器上运行,我应该如何更改路由或其他什么?

1 个答案:

答案 0 :(得分:3)

这两个实例无法共享侦听器端口。在第1课你有这个:

...
CREATE ENDPOINT InstTargetEndpoint
STATE = STARTED
AS TCP ( LISTENER_PORT = 4022 )
...

在第2课你有这个:

...
CREATE ENDPOINT InstInitiatorEndpoint
STATE = STARTED
AS TCP ( LISTENER_PORT = 4022 )
...

这不起作用,因为两个实例都配置为侦听同一TCP端口。一个必须是不同的。让目标听4023:

...
CREATE ENDPOINT InstTargetEndpoint
STATE = STARTED
AS TCP ( LISTENER_PORT = 4023 )
...

然后,从发起者到目标的路由必须现在指定端口4023:

...
CREATE ROUTE InstTargetRoute
WITH SERVICE_NAME =
       N''//TgtDB/2InstSample/TargetService'',
     ADDRESS = N''TCP://MyTargetComputer:4023'';';
...

其他一切都保持不变。