Wednesday, March 7, 2012

Can't receive messages on second server instance

Hi all!

Help, please!

I am trying to send messages between 2 different server instances. I am getting the following errors in Profiler:

"This message could not be delivered because the user with ID 0 in database ID 14 does not have permission to send to the service. Service name: 'TestService1'."

"The target service name could not be found. Ensure that the service name is specified correctly and/or the routing information has been supplied."

The scripts for object creation and messaging is following at the first server instance:

USE master
GO
CREATE ENDPOINT SBroker
STATE = STARTED
AS TCP ( LISTENER_PORT = 1212 )
FOR SERVICE_BROKER (
ENCRYPTION = DISABLED
);
GO


USE Test
GO
CREATE QUEUE TestQueue
WITH STATUS=ON

CREATE SERVICE TestService
AUTHORIZATION dbo
ON QUEUE TestQueue

CREATE ROUTE TestRoute
WITH
SERVICE_NAME = 'TestService1',
BROKER_INSTANCE ='2B7CE76A-9804-46F3-9AE8-0AE59313613A',
ADDRESS = 'TCP://10.17.11.17:4037' ;

// send message script:

DECLARE @.dh UNIQUEIDENTIFIER;

BEGIN DIALOG CONVERSATION @.dh
FROM SERVICE [TestService]
TO SERVICE 'TestService1','2B7CE76A-9804-46F3-9AE8-0AE59313613A'
ON CONTRACT [DEFAULT]
WITH ENCRYPTION = OFF;

SEND ON CONVERSATION @.dh MESSAGE TYPE [DEFAULT] ('this is message1');

DECLARE @.status nvarchar(1024);
SELECT status = GET_TRANSMISSION_STATUS(@.dh);

END CONVERSATION @.dh;

on second server instance:

use master
GO
CREATE ENDPOINT SBroker2
STATE = STARTED
AS TCP ( LISTENER_PORT = 1212 )
FOR SERVICE_BROKER (
ENCRYPTION = DISABLED
);
GO

in first server, in sys.transmission_queue transmission_status is empty

Both servers in the same domain, and databases on this server has the same owner.

on both servers, select @.@.version:
Microsoft SQL Server 2005 - 9.00.2047.00 (Intel X86)
Apr 14 2006 01:12:25 Copyright (c) 1988-2005 Microsoft Corporation
Developer Edition on Windows NT 5.2 (Build 3790: Service Pack 1)

Thanks a lot for help and explanation!

Sveta.


When you begin a dialog with encryption = off and there is no remote service binding for the target service in the initiator database, the inbound dialog at the target side will appear to be coming from user public (i.e. database principal 0). You will therefore need to grant send permission on the target service to user public. Of course, doing so means anyone can send messages to the target service.

If you want to authenticate the initiator, you will need to export the initiator service owner's certificate, create a user in the target database, import the certificate and make it owned by this user, and grant send permission for target service to this user. You could use Remus' Service Listings tool, which greatly simplied this process.

|||

Thank you for help,

after granting permission :

grant send on service::TestService1 to public

all messages received in second server.

No comments:

Post a Comment