none
External Activator not launching application!

    Frage

  • Hi,

    I am having the exact same problem, I have turned on verbose logging and still no luck.

    Error log doesn't appear to be showing much:

    6/12/2013 4:37:14 PM	INFO	The External Activator service is starting.
    6/12/2013 4:37:14 PM	INFO	Initializing configuration manager ...
    6/12/2013 4:37:14 PM	INFO	Reloading configuration file C:\Program Files\Service Broker\External Activator\config\EAService.config ...
    6/12/2013 4:37:14 PM	INFO	Reloading configuration file completed.
    6/12/2013 4:37:14 PM	VERBOSE	Running recovery using recovery log file C:\Program Files\Service Broker\External Activator\log\EARecovery.rlog ...
    6/12/2013 4:37:14 PM	VERBOSE	Checkpointing recovery log C:\Program Files\Service Broker\External Activator\log\EARecovery.rlog ...
    6/12/2013 4:37:14 PM	VERBOSE	Checkpointing recovery log completed.
    6/12/2013 4:37:14 PM	VERBOSE	Running recovery completed.
    6/12/2013 4:37:14 PM	INFO	Initializing configuration manager completed.
    6/12/2013 4:37:14 PM	VERBOSE	Starting worker threads...
    6/12/2013 4:37:14 PM	VERBOSE	CM-NS-Thread is starting...
    6/12/2013 4:37:14 PM	VERBOSE	Worker threads are successfully started.
    6/12/2013 4:37:14 PM	INFO	The External Activator service is running.
    6/12/2013 4:37:14 PM	VERBOSE	Heartbeat-Thread is starting...
    

    and my queues and services are as follows: 

    I assumed I was having issues with "poisoned message" and restarted the entire setup (even dropped the db). I still can't get it to launch my exe.

    Any suggestions would be greatly appreciated!

    Sam

    Mittwoch, 12. Juni 2013 22:55

Antworten

  • Does your config look like this:

    <ApplicationService name="myMessageApp" enabled="true">
          <OnNotification>
            <ServerName>WEBDEV</ServerName>
            <DatabaseName>AdventureWorks2012</DatabaseName>
            <SchemaName>dbo</SchemaName>
            <QueueName>TargetQueue</QueueName>
          </OnNotification>
          <LaunchInfo>
            <ImagePath>c:\test\myMessageReceiver.exe</ImagePath>
            <CmdLineArgs></CmdLineArgs>
            <WorkDir>c:\test</WorkDir>
          </LaunchInfo>
          <Concurrency min="1" max="1" />
        </ApplicationService>

    ?

    David


    David http://blogs.msdn.com/b/dbrowne/

    • Als Antwort markiert Sam Overmars Mittwoch, 19. Juni 2013 21:45
    Mittwoch, 19. Juni 2013 15:12

Alle Antworten

  • Not an answer.  But it's complexity like this combined with the External Activator's minimal added value that prompted me to write this sample

    Service Broker Message Processor Service Sample

    For how to write a stand-alone Windows service that does Service Broker message processing.

    David


    David http://blogs.msdn.com/b/dbrowne/

    Mittwoch, 12. Juni 2013 23:12
  • I wish I had the luxury of using that app but this is work related and I need to get this external activator up and running. Any suggestions on where I might be able to get some help?
    Donnerstag, 13. Juni 2013 14:45
  • I would walk through the external activator setup, from scratch, with a completely different database.  After you get that working, then return to your real database setup.

    It looks like your event notifications are not wired up correctly.  The way the External Activator works is that it doesn't just read from your queue (no, that would be too simple).  You create an event notification that generates a message whenever your queue triggers activation, and sends that to another queue, which the External Activator reads from.

    It looks like you are not generating those event notifications for some reason. 

    See, eg http://blog.maskalik.com/sql-server-service-broker/troubleshooting-external-activation

    David


    David http://blogs.msdn.com/b/dbrowne/

    Donnerstag, 13. Juni 2013 14:52
  • Hello,

    Can you see that messages are send to the notification queue? You can query directly the queue like a table, to see if messages have arrised.


    Olaf Helper

    Blog Xing

    Donnerstag, 13. Juni 2013 14:53
  • Thanks for your help, I have queried the tables (screenshot above). My messages make it to the external activator queue, the activator just doesnt launch my exe. Here is how I have the queues setup:


    ALTER DATABASE AdventureWorks2012 SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;

    CREATE MESSAGE TYPE [requestMessageType]
    VALIDATION = WELL_FORMED_XML

    CREATE MESSAGE TYPE [responseMessageType]
        VALIDATION = WELL_FORMED_XML

    CREATE CONTRACT [smtContract]
    (
    [requestMessageType] SENT BY INITIATOR,
    [responseMessageType] SENT BY TARGET
    )

    CREATE QUEUE InitiatorQueue
    WITH STATUS = ON

    CREATE QUEUE TargetQueue
    WITH STATUS = ON

    CREATE SERVICE InitiatorService
    ON QUEUE InitiatorQueue 
    (
        [smtContract]
    )

    CREATE SERVICE TargetService
    ON QUEUE TargetQueue
    (
        [smtContract]
    )

    CREATE QUEUE ExternalActivatorQueue 
    WITH STATUS = ON


    CREATE SERVICE ExternalActivatorService
    ON QUEUE ExternalActivatorQueue
    (
        [http://schemas.microsoft.com/SQL/Notifications/PostEventNotification]
    )

    CREATE EVENT NOTIFICATION EventNotificationTargetQueue 
        ON QUEUE TargetQueue
        FOR QUEUE_ACTIVATION
        TO SERVICE 'ExternalActivatorService', 'current database';


    CREATE TABLE [Order]
    (
        ID int identity(1000,1) NOT NULL,
        Amount MONEY NOT NULL
    )

    -- Trigger will add a message into a ImportQueue
    Create TRIGGER OnOrderInserted ON [Order] FOR INSERT
    AS
    BEGIN 
        BEGIN TRANSACTION;
            DECLARE @ch UNIQUEIDENTIFIER
            DECLARE @messageBody NVARCHAR(MAX);

            BEGIN DIALOG CONVERSATION @ch
                    FROM SERVICE [InitiatorService]
                    TO SERVICE 'TargetService'
                    ON CONTRACT [smtContract]
                    WITH ENCRYPTION = OFF;

            -- Construct the request message
            SET @messageBody = (SELECT ID, Amount FROM [Order] FOR XML AUTO, ELEMENTS);

            -- Send the message to the TargetService
            ;SEND ON CONVERSATION @ch
            MESSAGE TYPE [requestMessageType] (@messageBody);
        COMMIT;
    END 
    GO


    alter authorization on database::AdventureWorks2012 to [sa];


    ALTER QUEUE InitiatorQueue
    WITH ACTIVATION 
    (
        PROCEDURE_NAME = ProcessResponseMessages,
        STATUS = ON,
        MAX_QUEUE_READERS = 1,
        EXECUTE AS OWNER
    )

    Donnerstag, 13. Juni 2013 15:29
  • Exactly what version and service pack is this?

    David


    David http://blogs.msdn.com/b/dbrowne/

    Donnerstag, 13. Juni 2013 16:39
  • Sorry, forgot the details:

    SQL Server 2012

    .NET 4.0

    Wind 7 SP1

    Please let me know if I left something out and thanks again!

    Donnerstag, 13. Juni 2013 16:48
  • If you can, update to SQL Server 2012 SP1 CU4 and troubleshoot by shutting down the External Activator service and running

    select * from ExternalActivatorQueue with (nolock);

    To verify that you are generating queue activation event notifications.  You won't get a notification for every message.  And you may need to clear the queue to get a new notification.

    See:

    For external applications, Service Broker has no information on the number of distinct queue readers that may be working with the queue. Further, there may be some start up time required between the time that the activation event is raised and the time that a reader begins reading the queue. Therefore, Service Broker provides a time-out for an external application to respond. During the time-out, Service Broker will not produce another notification. Once an application calls RECEIVE on the queue or the time-out expires, Service Broker creates another event notification if activation is required. An external application monitors the event notifications while the program is running to determine whether more queue readers are required to read events.

    http://msdn.microsoft.com/en-us/library/ms171601(v=sql.105).aspx

    David


    David http://blogs.msdn.com/b/dbrowne/


    Donnerstag, 13. Juni 2013 17:03
  • I got some clarification on the question of when the notifications are sent.  In particular if a notification is sent and you don't clear the queue, no further notifications will be sent.

    For the External Activator this means that if you don't have the configuration correct the first time you start it up, it can consume the only event notification and fail to launch your application.  You'll need to clear the queue and send more messages for new activation messages to be sent.

    David


    David http://blogs.msdn.com/b/dbrowne/

    Donnerstag, 13. Juni 2013 20:02
  • select * from ExternalActivatorQueue with (nolock);

    In your screenshot there is already a select on the ExternalActivatorQueue and the result is empty; without notifictaion messages the External Activator won't start.


    Olaf Helper

    Blog Xing

    Freitag, 14. Juni 2013 05:24
  • @Olaf,

    Thanks for the reply, the Events are getting to the External Quque, its empty in the screen shot because I have a C# app that contiously polls that queue. I can read messages off of the queue with no problems, I just can't get SQL to launch the external app.

    Thanks again!

    Sam

    Freitag, 14. Juni 2013 21:15
  • That is actually very helpful, I will debug using this new tidbit, thnx
    Freitag, 14. Juni 2013 21:16
  • To clarify, ExternalActivatorQueue in the script you sent is where the activation notifications go. You should not be reading from that queue if you are using the external activator.

    David


    David http://blogs.msdn.com/b/dbrowne/

    Freitag, 14. Juni 2013 22:31
  • Im sorry but what does that have to do with the external activator not launching my exe?
    Montag, 17. Juni 2013 21:21
  • >Im sorry but what does that have to do with the external activator not launching my exe?

    The job of the external activator is to read from the ExternalActivatorQueue and launch your exe. If it doesn't find any activation messages, it will never launch your exe.

    To recap, here's how it's supposed to work:

    1) You have a TargetQueue.  

    2) You have an event notification configured on the TargetQueue so that whenever the queue needs actication sends a message to ExternalActivatorQueue

    3) The External Activator service reads from the ExternalActivatorQueue and launches your exe.

    4) Your exe RECEIVEs all available messages from TargetQueue and does useful stuff, then exits.

    5) TargetQueue is now empty and the next message to arrive will cause a new activation event, and a new message to appear on ExternalActivatorQueue.  GOTO 3)

    However if you ever get in a state where you have messages in TargetQueue and no message in ExternalActivatorQueue, the External Activator service will _never_ launch your exe.  That's what appears to be the case in the screenshot.  And so the question is: Why is the ExternalActivatorQueue empty? 

    David


    David http://blogs.msdn.com/b/dbrowne/

    Dienstag, 18. Juni 2013 02:01
  • Thank you for the reply!!

    So I reset everything, wiped my db and started from scratch. I got messages pushing through to the external activator but I still can't get it to launch my exe. I looked in the EATrace log and found:


    2013-06-18 8:30:40 PM ====== ================================================================================
    2013-06-18 8:30:40 PM INFO The External Activator service is starting.
    2013-06-18 8:30:40 PM INFO Initializing configuration manager ...
    2013-06-18 8:30:40 PM INFO Reloading configuration file C:\Program Files\Service Broker\External Activator\config\EAService.config ...
    2013-06-18 8:30:40 PM INFO Reloading configuration file completed.
    2013-06-18 8:30:40 PM INFO Initializing configuration manager completed.
    2013-06-18 8:30:40 PM INFO The External Activator service is running.
    2013-06-18 8:37:59 PM EXCEPTION ERROR = 32, No enabled application monitor is on behalf of queue [WEBDEV].[AdventureWorks2012].[dbo].[TargetQueue].
    2013-06-18 8:48:06 PM EXCEPTION ERROR = 32, No enabled application monitor is on behalf of queue [WEBDEV].[AdventureWorks2012].[dbo].[TargetQueue].

    I googled the heck out of it and only solution was not to use localhost but my config is as follows:

     ?xml version="1.0" encoding="utf-8"?>
    <Activator xmlns="http://schemas.microsoft.com/sqlserver/2008/10/servicebroker/externalactivator"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://schemas.microsoft.com/sqlserver/2008/10/servicebroker/externalactivator EAServiceConfig.xsd"
               >
      <NotificationServiceList>
        <NotificationService name="ExternalActivatorService" id="100" enabled="true">
          <Description>Alinity Notification</Description>
          <ConnectionString>
            <!-- All connection string parameters except User Id and Password should be specificed here -->
            <Unencrypted>server=webDev;database=AdventureWorks2012;Application Name=Alinity External Activator;Integrated Security=true;</Unencrypted>
          </ConnectionString>
        </NotificationService>
      </NotificationServiceList>
      <ApplicationServiceList>
        <ApplicationService name="AlinityMessaging" enabled="true">
          <OnNotification>
            <ServerName>webDev</ServerName>
            <DatabaseName>AdventureWorks2012</DatabaseName>
            <SchemaName>dbo</SchemaName>
            <QueueName>ExternalActivatorQueue</QueueName>
          </OnNotification>
          <LaunchInfo>
            <ImagePath>c:\test\ProcessingApplication.exe</ImagePath>
            <CmdLineArgs></CmdLineArgs>
            <WorkDir>c:\test</WorkDir>
          </LaunchInfo>
          <Concurrency min="1" max="1" />
        </ApplicationService>
      </ApplicationServiceList>
      <LogSettings>
        <LogFilter>
        </LogFilter>
      </LogSettings>
    </Activator>

    and I used the following sql commands:


    ALTER DATABASE AdventureWorks2012 SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;
    SELECT name, is_broker_enabled FROM sys.databases 

    Create message type [requestMessage]

    Create message type [responseMessage]

    Create contract [ssbContract]
    (
    [requestMessage] sent by initiator,
    [responseMessage] sent by target
    )

    CREATE QUEUE InitiatorQueue
    WITH STATUS = ON

    CREATE QUEUE TargetQueue
    WITH STATUS = ON


    CREATE SERVICE InitiatorService
    ON QUEUE InitiatorQueue 
    (
        [ssbContract]
    )

    CREATE SERVICE TargetService
    ON QUEUE TargetQueue
    (
        [ssbContract]
    )

    CREATE QUEUE ExternalActivatorQueue

    CREATE SERVICE ExternalActivatorService
    ON QUEUE ExternalActivatorQueue
    (
        [http://schemas.microsoft.com/SQL/Notifications/PostEventNotification]
    )

    CREATE EVENT NOTIFICATION EventNotificationTargetQueue
        ON QUEUE TargetQueue
        FOR QUEUE_ACTIVATION
        TO SERVICE 'ExternalActivatorService', 'current database';


    CREATE TABLE [Order]
    (
        ID int identity(1,1) NOT NULL,
        Amount MONEY NOT NULL
    )

    -- Trigger will add a message into a ImportQueue
    CREATE TRIGGER OnOrderInserted ON [Order] FOR INSERT
    AS
    BEGIN 
        BEGIN TRANSACTION;
            DECLARE @ch UNIQUEIDENTIFIER
            DECLARE @messageBody NVARCHAR(MAX);

            BEGIN DIALOG CONVERSATION @ch
                    FROM SERVICE [InitiatorService]
                    TO SERVICE 'TargetService'
                    ON CONTRACT [ssbContract]
                    WITH ENCRYPTION = OFF;

            -- Construct the request message
            SET @messageBody = (SELECT ID, Amount FROM [Order] FOR XML AUTO, ELEMENTS);

            -- Send the message to the TargetService
            ;SEND ON CONVERSATION @ch
            MESSAGE TYPE [requestMessage] (@messageBody);
        COMMIT;
    END 
    GO



    alter authorization on database::[AdventureWorks2012] to [sa];
    alter authorization on database::[AdventureWorks2012] to [webDev\Admin];

    insert into [Order] (Amount) values ('55.55')

    select * from dbo.TargetQueue
    select * from dbo.ExternalActivatorQueue

    select * from sys.transmission_queue

    As I mentioned in an earlier thread, if I poll the TargetQueue I can read the messages but still can't get it to launch. Thanks in advance because any help is appreciated!

    Sam

     
    Mittwoch, 19. Juni 2013 03:09
  • >I googled the heck out of it and only solution was not to use localhost but my config is as follows:

    I can confirm that your config needs to reference your server by server name, not localhost.  What happened when you corrected the config file, cleared the target queue and sent another message?

    David


    David http://blogs.msdn.com/b/dbrowne/

    Mittwoch, 19. Juni 2013 04:25
  • That is the error message I got after corrected the config file and sent another message.

    Do I need to do something special to start/mark my service as an external activator service in sql? I am missing what's telling SQL that the 'ExternalActivatorService' is an external activator. Is is this line:

    CREATE EVENT NOTIFICATION EventNotificationTargetQueue
        ON QUEUE TargetQueue
        FOR QUEUE_ACTIVATION   ---------> ????? This??
        TO SERVICE 'ExternalActivatorService', 'current database';

    I'm so stuck!!! Thnx for your help!

    Mittwoch, 19. Juni 2013 14:15
  • ERROR = 32, No enabled application monitor is on behalf of queue [WEBDEV].[AdventureWorks2012].[dbo].[TargetQueue].

    How can I resolve this?

    Mittwoch, 19. Juni 2013 14:16
  • Does your config look like this:

    <ApplicationService name="myMessageApp" enabled="true">
          <OnNotification>
            <ServerName>WEBDEV</ServerName>
            <DatabaseName>AdventureWorks2012</DatabaseName>
            <SchemaName>dbo</SchemaName>
            <QueueName>TargetQueue</QueueName>
          </OnNotification>
          <LaunchInfo>
            <ImagePath>c:\test\myMessageReceiver.exe</ImagePath>
            <CmdLineArgs></CmdLineArgs>
            <WorkDir>c:\test</WorkDir>
          </LaunchInfo>
          <Concurrency min="1" max="1" />
        </ApplicationService>

    ?

    David


    David http://blogs.msdn.com/b/dbrowne/

    • Als Antwort markiert Sam Overmars Mittwoch, 19. Juni 2013 21:45
    Mittwoch, 19. Juni 2013 15:12
  • Everything except the QueueName, I assumed the QueueName would be the ExternalActivatorQueue, no?

    I will retry using TargetQueue as the QueueName.
    • Bearbeitet Sam Overmars Mittwoch, 19. Juni 2013 19:05 Update
    Mittwoch, 19. Juni 2013 19:04
  • Thank you so much for your help!

    There were many issues so I'm not 100% sure what the solution was but I changed the QueueName to 'TargetQueue' and set security permissions to both the folder of the managed code and db permissions to user.

    Mittwoch, 19. Juni 2013 21:47