Message from SQL Server to external application (a

2019-03-01 12:13发布

I have a SQL Server database and Activemq installed in my system. I tried to create the endpoint to listen to the port where activemq is. The port is 61617

CREATE ENDPOINT InstInitiatorEndpoint
STATE = STARTED
AS TCP ( LISTENER_PORT = 61617 )
FOR SERVICE_BROKER (AUTHENTICATION = WINDOWS );
GO

But it results in an error:

The Service Broker endpoint cannot listen for connections due to the following error: '10013(An attempt was made to access a socket in a way forbidden by its access permissions.)'.

Since activemq is already running on same port. Should I give different port? If I give different port number then it is executing successfully. But basically LISTENER_PORT=61617 means the endpoint listen to port 61617, isn't it? can anyone clarify my doubt?

EDIT: Let us assume I have created endpoint, message type, contract, queue and service as follows

 CREATE MESSAGE TYPE RequestMessage
   VALIDATION = WELL_FORMED_XML;
 CREATE MESSAGE TYPE ReplyMessage
   VALIDATION = WELL_FORMED_XML;
 GO



 CREATE CONTRACT SimpleContract
  (RequestMessage
     SENT BY INITIATOR,
   ReplyMessage
     SENT BY TARGET
  );
 GO


  CREATE QUEUE InstInitiatorQueue;

 CREATE SERVICE InitiatorService
   AUTHORIZATION InitiatorUser
   ON QUEUE InstInitiatorQueue;
 GO



DECLARE @Cmd NVARCHAR(4000);

SET @Cmd = N'USE InstInitiatorDB;
CREATE ROUTE InstTargetRoute
WITH SERVICE_NAME =
   N''TargetService'',
 ADDRESS = N''TCP://localhost:61617'';';

EXEC (@Cmd);

DECLARE @Cmd NVARCHAR(4000);
SET @Cmd = N'USE msdb
CREATE ROUTE InstInitiatorRoute
WITH SERVICE_NAME =
   N''InitiatorService'',
 ADDRESS = N''LOCAL''';

 EXEC (@Cmd);
GO

CREATE REMOTE SERVICE BINDING TargetBinding
  TO SERVICE
     N'TargetService'
  WITH USER = TargetUser;

GO

Now I create handle for the conversation as

 DECLARE @InitDlgHandle UNIQUEIDENTIFIER;
 DECLARE @RequestMsg NVARCHAR(100);

 BEGIN TRANSACTION;

 BEGIN DIALOG @InitDlgHandle
 FROM SERVICE InitiatorService
 TO SERVICE N'TargetService'
 ON CONTRACT SimpleContract
 WITH
     ENCRYPTION = ON;

 SELECT @RequestMsg = N'<RequestMsg>Message for Target service434.</RequestMsg>';

 SEND ON CONVERSATION @InitDlgHandle
 MESSAGE TYPE RequestMessage
 (@RequestMsg);

SELECT @RequestMsg AS SentRequestMsg;

COMMIT TRANSACTION;
GO

Here If you see I tried the example of conversation between two SQL server instance to make conversation between SQL server and activemq. I need to specify server to server communication, for that I need to specify service(Initiator) to service(target). I know the initiator server that is sql server, But I don't know the activemq's service. What would be the activemq's service I should specify in handle conversation at database side?

0条回答
登录 后发表回答