No enabled application monitor is on behalf of queue XYZ

自作多情 提交于 2019-12-04 02:01:25

问题


I created a console application which will be used by "Service Broker External Activator" service. The configuration file in "C:\Program Files\Service Broker\External Activator\Config" has been changed, but it writes an exception to log file as bellow

EXCEPTION ERROR = 32, No enabled application monitor is on behalf of queue

Here is my configuration

<NotificationServiceList>
    <NotificationService name="ExternalActivatorService" id="100" enabled="true">
      <Description>My test notification service</Description>
      <ConnectionString>
        <!-- All connection string parameters except User Id and Password should be specificed here -->
        <Unencrypted>Data Source=localhost;Initial Catalog=Chapter4_ExternalActivation;Application Name=External Activator;Integrated Security=True;</Unencrypted>
      </ConnectionString>
    </NotificationService>
  </NotificationServiceList>
  <ApplicationServiceList>
        <ApplicationService name="ProcessingApplication" enabled="true">
      <OnNotification>
        <ServerName>localhost</ServerName>
        <DatabaseName>Chapter4_ExternalActivation</DatabaseName>
        <SchemaName>dbo</SchemaName>
        <QueueName>ExternalActivatorQueue</QueueName>
      </OnNotification>
      <LaunchInfo>
        <ImagePath>D:\Temp\ServiceBroker\9781590599990\Samples\Chapter4\02 ExternalProcessingApplication\ProcessingApplication\bin\Debug\ProcessingApplication.exe</ImagePath>
        <CmdLineArgs></CmdLineArgs>
        <WorkDir>D:\Temp\ServiceBroker\9781590599990\Samples\Chapter4\02 ExternalProcessingApplication\ProcessingApplication\bin\Debug</WorkDir>
      </LaunchInfo>
      <Concurrency min="1" max="1" />
    </ApplicationService>
  </ApplicationServiceList>

And here is the SQL

CREATE DATABASE Chapter4_ExternalActivation
GO

ALTER DATABASE Chapter4_ExternalActivation
      SET ENABLE_BROKER;
GO

USE Chapter4_ExternalActivation
GO

--*********************************************
--*  Create the message type "RequestMessage"
--*********************************************
CREATE MESSAGE TYPE
[http://ssb.csharp.at/SSB_Book/c04/RequestMessage]
VALIDATION = WELL_FORMED_XML
GO

--*********************************************
--*  Create the message type "ResponseMessage"
--*********************************************
CREATE MESSAGE TYPE
[http://ssb.csharp.at/SSB_Book/c04/ResponseMessage]
VALIDATION = WELL_FORMED_XML
GO

--************************************************
--*  Create the contract "HelloWorldContract"
--************************************************
CREATE CONTRACT [http://ssb.csharp.at/SSB_Book/c04/HelloWorldContract]
(
    [http://ssb.csharp.at/SSB_Book/c04/RequestMessage] SENT BY INITIATOR,
    [http://ssb.csharp.at/SSB_Book/c04/ResponseMessage] SENT BY TARGET
)
GO

 --********************************************************
--*  Create the queues "InitiatorQueue" and "TargetQueue"
--*********************************************************
CREATE QUEUE InitiatorQueue
WITH STATUS = ON
GO

CREATE QUEUE TargetQueue
GO

 --**************************************************************
--*  Create the services "InitiatorService" and "TargetService"
--***************************************************************
CREATE SERVICE InitiatorService
ON QUEUE InitiatorQueue 
(
    [http://ssb.csharp.at/SSB_Book/c04/HelloWorldContract]
)
GO

CREATE SERVICE TargetService
ON QUEUE TargetQueue
(
    [http://ssb.csharp.at/SSB_Book/c04/HelloWorldContract]
)
GO

 --******************************************************************
--*  Deactivate the internal activation on the queue (if necessary)
--*******************************************************************
ALTER QUEUE TargetQueue
    WITH ACTIVATION (DROP)
GO

--*********************************************
--*  Create the event notification queue
--*********************************************
CREATE QUEUE ExternalActivatorQueue
GO

--*********************************************
--*  Create the event notification service
--*********************************************
CREATE SERVICE ExternalActivatorService
ON QUEUE ExternalActivatorQueue
(
    [http://schemas.microsoft.com/SQL/Notifications/PostEventNotification]
)
GO

--***********************************************************************
--*  Subscribe to the QUEUE_ACTIVATION event on the queue "TargetQueue"
--***********************************************************************
CREATE EVENT NOTIFICATION EventNotificationTargetQueue
    ON QUEUE TargetQueue
    FOR QUEUE_ACTIVATION
    TO SERVICE 'ExternalActivatorService', 'current database';
GO

When I send a message to TargetService, new message arrives on ExternalActivatorQueue. When I start the "Service Broker External Activator" service, error appears. Any idea to find out the source of this problem?


回答1:


This may help you if issue still exists.

If all the SSSB objects and event notification set properly then need to see, how message is getting push to notification queue.

Below is the message format you have to use and send it to notification queue,

DECLARE @RequestMsg XML
SELECT @RequestMsg = N'<EVENT_INSTANCE>
   <EventType>QUEUE_ACTIVATION</EventType>
   <PostTime>' + CONVERT(CHAR(24),GETDATE(),126) + '</PostTime> 
   <SPID>' + CAST(@@SPID AS VARCHAR(9)) + '</SPID> 
   <ServerName>ServerName</ServerName>   -- use @@SERVERNAME to eliminate hard code 
   <LoginName></LoginName>    -- you can skip this element 
   <UserName></UserName>      -- you can skip this element 
   <DatabaseName>DatabaseName</DatabaseName> -- use DB_NAME() to eliminate hard code 
   <SchemaName>dbo</SchemaName>
   <ObjectName>NotifyQueue</ObjectName>
   <ObjectType>QUEUE</ObjectType>
</EVENT_INSTANCE>';

Also be careful with the values in each section of the message it should match with config values of [EAService.config], see the comments in above XML structure.

 <ApplicationService name="myMessageApp" enabled="true">
  <OnNotification>
    <ServerName>ServerName</ServerName>
    <DatabaseName>DatabaseName</DatabaseName>
    <SchemaName>dbo</SchemaName>
    <QueueName>NotifyQueue</QueueName>
  </OnNotification>
  <LaunchInfo>

The reason for doing this way is, there is logic in service which do match of SSSB message values with values of EAService.Config, on successful match given application is getting executed.

Hope this will help you if you are having same issue alive.




回答2:


The more likely cause for this is that you are using "localhost" in the ServerName element. I just reproduced it in my working example by changing ServerName to localhost.

The ServerName and the ConnectionString's server MUST be an actual computer name, a machine name specifically, not a DNS name either.

If you make the ConnectionString's server localhost, then nothing will happen after the service starts. You won't get an error, but activation will not occur.



来源:https://stackoverflow.com/questions/15359859/no-enabled-application-monitor-is-on-behalf-of-queue-xyz

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!