0

我有 2 个队列和更多队列...我想使用外部激活器从外部激活这些队列。

当我编辑 EAService.config 以激活 queue#1 时,它工作得很好。
当我编辑 EAService.config 以激活 queue#2 时,它工作得很好。

如果我将两者都放在配置中,则只有第一个列出的那个会被激活。

两个队列实际上都由同一个 exe 处理......而不起作用的例子是......

<NotificationServiceList>
    <NotificationService name="my_notif_svc1" id="100" enabled="true">
      <Description>my notification service 1</Description>
      <ConnectionString>
        <Unencrypted>server=my_pc01;database=my_db;Application Name=External Activator;Integrated Security=true;</Unencrypted>
      </ConnectionString>
    </NotificationService>
    <NotificationService name="my_notif_svc2" id="100" enabled="true">
      <Description>my notification service 2</Description>
      <ConnectionString>
        <Unencrypted>server=my_pc01;database=my_db;Application Name=External Activator;Integrated Security=true;</Unencrypted>
      </ConnectionString>
    </NotificationService>
  </NotificationServiceList>
  <ApplicationServiceList>
    <ApplicationService name="myMessageApp1" enabled="true">
      <OnNotification>
        <ServerName>my_pc01</ServerName>
        <DatabaseName>my_db</DatabaseName>
        <SchemaName>dbo</SchemaName>
        <QueueName>my_user_queue1</QueueName>
      </OnNotification>
      <LaunchInfo>
        <ImagePath>c:\test\myMessageReceiver.exe</ImagePath>
        <CmdLineArgs>whatever cmd-line arguments you need to pass to your receiver application</CmdLineArgs>
        <WorkDir>c:\test</WorkDir>
      </LaunchInfo>
      <Concurrency min="1" max="4" />
    </ApplicationService>
    <ApplicationService name="myMessageApp2" enabled="true">
      <OnNotification>
        <ServerName>my_pc01</ServerName>
        <DatabaseName>my_db</DatabaseName>
        <SchemaName>dbo</SchemaName>
        <QueueName>my_user_queue2</QueueName>
      </OnNotification>
      <LaunchInfo>
        <ImagePath>c:\test\myMessageReceiver.exe</ImagePath>
        <CmdLineArgs>whatever cmd-line arguments you need to pass to your receiver application</CmdLineArgs>
        <WorkDir>c:\test</WorkDir>
      </LaunchInfo>
      <Concurrency min="1" max="4" />
    </ApplicationService>
  </ApplicationServiceList>

另外我不明白 id="100" 在做什么...我尝试使用相同的 # 和不同的 #... 即 100 和 101 但它没有任何区别。激活器服务仅适用于“ApplicationServiceList”中列出的第一个

帮助!

4

2 回答 2

1

我发现了我的问题...

从文档

系统可以对多个 Service Broker 应用程序队列使用外部激活。应用程序队列和激活通知服务之间存在多对一的关系。激活通知服务和外部激活服务之间存在一对一的关系。

我是上面列出的两个通知服务(my_notif_svc1 和 my_notif_svc2)。我切换了我的事件通知(创建事件通知...)以使用相同的“TO SERVICE”,现在它可以工作了。

因此,您必须为外部激活器使用一个“服务”,但您可以为指向该服务的多个队列创建多个事件通知。

我仍然认为我设置它的方式应该可以工作,但这绝对有效......

于 2011-02-21T18:30:41.880 回答
0

我也遇到了同样的问题,如果微软官方回应他们为什么以及是否会尊重 SSBEA 中列出的多个通知服务,而不仅仅是列表中的第一个,那就太好了。最后,我们采用了相同的解决方案,这里有一个有用的片段,用于动态获取 Guid 并将队列激活事件设置为单个服务 (ServiceBrokerNotification.NotificationService)。

DECLARE @sbn nvarchar(100) = 'servicebrokernotification'
DECLARE @sbnid nvarchar(60)

SELECT @sbnid = ''''+CAST(service_broker_guid AS nvarchar(60))+'''' FROM sys.databases WHERE name = @sbn SELECT @sbnid

DECLARE @Str nvarchar(max) DECLARE @createEventSql nvarchar(max)

Set @Str = 'CREATE EVENT NOTIFICATION NotificationEvent ON QUEUE [TargetQueue] FOR QUEUE_ACTIVATION TO SERVICE ''NotificationService'' ,' + @sbnid;

Select @Str EXECUTE (@Str)

于 2011-04-22T20:31:59.700 回答