1

I am following the Completing a Conversation Between Instances tutorial from MSDN. The Lesson 2: Creating the Initiator Database (at the end) shows, how to create routes at the initiator site (shortened):

...
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'

and the Lesson 3: Completing the Target Conversation Objects does the same on the target instance:

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';

However, the tutorial assumes that the SQL server instances run on separate hardware. How should I change the routing or whatever if the two SQL server instances run on the same machine?

Cœur
  • 37,241
  • 25
  • 195
  • 267
pepr
  • 20,112
  • 15
  • 76
  • 139

1 Answers1

3

The two instances cannot share the listener port. On Lesson 1 you had this:

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

and on Lesson 2 you had this:

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

This will not work as both instances are configured to listen on the same TCP port. One has to be different. Lets make the target listen on 4023:

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

Then the route from the initiator to the target has to specify port 4023 now:

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

Everything else stays the same.

Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
  • If I understand it well, the `4022` is the usual port number for the purpose. Are there any recommendations what a different port should be used? I have seen somewhere also `5022`. I understand that the 4022 is actually by convention, and one could use almost whatever free port. But what is *a good behaviour*? – pepr Jul 19 '12 at 16:52
  • Is there a reason msdb is employed in the example? Is that what production environment should use? – milez Jul 19 '16 at 11:34
  • @milez please ask a separate question. – Remus Rusanu Jul 19 '16 at 12:01
  • @RemusRusanu I asked here http://stackoverflow.com/q/38472867/5110359 :) – milez Jul 20 '16 at 08:03