我创建了一个控制台应用程序,将由“Service BrokerExternal Activator”服务使用。 “C:\Program Files\Service Broker\External Activator\Config”中的配置文件已更改,但它会向日志文件写入异常,如下所示
异常错误 = 32,没有启用的应用程序监视器代表队列
这是我的配置
<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>
这是 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
当我向 TargetService 发送消息时,新消息到达ExternalActivatorQueue。当我启动“Service BrokerExternal Activator”服务时,出现错误。有想法找出这个问题的根源吗?
如果问题仍然存在,这可能会对您有所帮助。
如果所有 SSSB 对象和事件通知设置正确,则需要查看消息如何推送到通知队列。
以下是您必须使用并将其发送到通知队列的消息格式,
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>';
另请注意消息每个部分中的值,它应与 [EAService.config] 的配置值匹配,请参阅上面 XML 结构中的注释。
<ApplicationService name="myMessageApp" enabled="true">
<OnNotification>
<ServerName>ServerName</ServerName>
<DatabaseName>DatabaseName</DatabaseName>
<SchemaName>dbo</SchemaName>
<QueueName>NotifyQueue</QueueName>
</OnNotification>
<LaunchInfo>
这样做的原因是,服务中有一个逻辑将 SSSB 消息值与 EAService.Config 的值进行匹配,成功匹配后,给定的应用程序将被执行。
如果您遇到同样的问题,希望这会对您有所帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)