Hi, I am pulling out my hair. for a day and 1/2 i have messed with this and still cannot get it to work.
I am using sql2012
following this article http://devkimchi.com/811/service-broker-external-activator-for-sql-server-step-by-step-1/
I have a Active Directory User call WWProgramming\ExternalActivator
Installed External Activator package.
My External application is not running, i should get an entry in the eventlog stating we made it to main()
Please some help would be great.
Create DB.
USE [master] GO /****** Object: Database [Test] Script Date: 6/19/2015 12:22:02 PM ******/ CREATE DATABASE [Test] CONTAINMENT = NONE ON PRIMARY ( NAME = N'Test', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\Test.mdf' , SIZE = 4096KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N'Test_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\Test_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) GO ALTER DATABASE [Test] SET COMPATIBILITY_LEVEL = 110 GO IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled')) begin EXEC [Test].[dbo].[sp_fulltext_database] @action = 'enable' end GO ALTER DATABASE [Test] SET ANSI_NULL_DEFAULT OFF GO ALTER DATABASE [Test] SET ANSI_NULLS OFF GO ALTER DATABASE [Test] SET ANSI_PADDING OFF GO ALTER DATABASE [Test] SET ANSI_WARNINGS OFF GO ALTER DATABASE [Test] SET ARITHABORT OFF GO ALTER DATABASE [Test] SET AUTO_CLOSE OFF GO ALTER DATABASE [Test] SET AUTO_CREATE_STATISTICS ON GO ALTER DATABASE [Test] SET AUTO_SHRINK OFF GO ALTER DATABASE [Test] SET AUTO_UPDATE_STATISTICS ON GO ALTER DATABASE [Test] SET CURSOR_CLOSE_ON_COMMIT OFF GO ALTER DATABASE [Test] SET CURSOR_DEFAULT GLOBAL GO ALTER DATABASE [Test] SET CONCAT_NULL_YIELDS_NULL OFF GO ALTER DATABASE [Test] SET NUMERIC_ROUNDABORT OFF GO ALTER DATABASE [Test] SET QUOTED_IDENTIFIER OFF GO ALTER DATABASE [Test] SET RECURSIVE_TRIGGERS OFF GO ALTER DATABASE [Test] SET ENABLE_BROKER GO ALTER DATABASE [Test] SET AUTO_UPDATE_STATISTICS_ASYNC OFF GO ALTER DATABASE [Test] SET DATE_CORRELATION_OPTIMIZATION OFF GO ALTER DATABASE [Test] SET TRUSTWORTHY OFF GO ALTER DATABASE [Test] SET ALLOW_SNAPSHOT_ISOLATION OFF GO ALTER DATABASE [Test] SET PARAMETERIZATION SIMPLE GO ALTER DATABASE [Test] SET READ_COMMITTED_SNAPSHOT OFF GO ALTER DATABASE [Test] SET HONOR_BROKER_PRIORITY OFF GO ALTER DATABASE [Test] SET RECOVERY FULL GO ALTER DATABASE [Test] SET MULTI_USER GO ALTER DATABASE [Test] SET PAGE_VERIFY CHECKSUM GO ALTER DATABASE [Test] SET DB_CHAINING OFF GO ALTER DATABASE [Test] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) GO ALTER DATABASE [Test] SET TARGET_RECOVERY_TIME = 0 SECONDS GO ALTER DATABASE [Test] SET READ_WRITE GO
Create Messages
USE Test GO CREATE MESSAGE TYPE [TrackingRequest] VALIDATION = WELL_FORMED_XML GO CREATE MESSAGE TYPE [TrackingResponse] VALIDATION = NONE GO
Create Contract
USE Test GO CREATE CONTRACT [TrackingContract] ( [TrackingRequest] SENT BY INITIATOR, [TrackingResponse] SENT BY TARGET ) GO
Create Queues and Services
USE Test GO CREATE QUEUE [TrackingRequestQueue] WITH STATUS = ON GO CREATE QUEUE [TrackingResponseQueue] WITH STATUS = ON GO CREATE QUEUE [TrackingNotificationQueue] GO CREATE SERVICE [TrackingInitiatorService] ON QUEUE [dbo].[TrackingResponseQueue] ([TrackingContract]); GO CREATE SERVICE [TrackingTargetService] ON QUEUE [dbo].[TrackingRequestQueue] ([TrackingContract]); GO CREATE SERVICE [TrackingNotificationService] ON QUEUE [dbo].[TrackingNotificationQueue] ([http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification]); GO
Create Event Notification
USE Test GO CREATE EVENT NOTIFICATION [TrackingEventNotification] ON QUEUE [dbo].[TrackingRequestQueue] FOR QUEUE_ACTIVATION TO SERVICE 'TrackingNotificationService', 'current database' GO
SQL Permissions
USE [master] GO IF NOT EXISTS (SELECT name FROM Master.sys.server_principals WHERE name = 'WWProgramming\ExternalActivator') BEGIN CREATE LOGIN [WWProgramming\ExternalActivator] FROM WINDOWS WITH DEFAULT_DATABASE=[Test] END GO USE [Test] GO IF NOT EXISTS (SELECT name FROM sys.database_principals WHERE name = 'WWProgramming\ExternalActivator') BEGIN CREATE USER [WWProgramming\ExternalActivator] FOR LOGIN [WWProgramming\ExternalActivator] END GO ALTER ROLE [db_owner] Add MEMBER [WWProgramming\ExternalActivator] GO USE [Test] GO GRANT CONNECT TO [WWProgramming\ExternalActivator] GO GRANT RECEIVE ON [dbo].[TrackingNotificationQueue] TO [WWProgramming\ExternalActivator] GO GRANT VIEW DEFINITION ON SERVICE::TrackingNotificationService TO [WWProgramming\ExternalActivator] GO GRANT REFERENCES ON SCHEMA::dbo TO [WWProgramming\ExternalActivator] GO
EAService.config
<?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><!-- name - service broker service name which is associated with event notification --><NotificationService name="TrackingNotificationService" id="100" enabled="true"><Description>Tracking Notification Service</Description><ConnectionString><!-- restriction - connection string must have enabled integrated security --><Unencrypted>Server=MJ08W37\MSSQLSERVER2012;database=Test;Application Name=External Activator;Integrated Security=True;</Unencrypted></ConnectionString></NotificationService></NotificationServiceList><ApplicationServiceList><ApplicationService name="MessageProcessingApplication" enabled="true"><OnNotification><!-- sql server full instance name --><ServerName>MJ08W37\MSSQLSERVER2012</ServerName><DatabaseName>Test</DatabaseName><SchemaName>dbo</SchemaName><!-- user queue name, not notification one --><QueueName>TrackingRequestQueue</QueueName></OnNotification><LaunchInfo><ImagePath>c:\test\MessageProcessingApplication.exe</ImagePath><CmdLineArgs> %sqlserver% %database% %schema% %queue% </CmdLineArgs><WorkDir>c:\test</WorkDir></LaunchInfo><Concurrency min="1" max="4" /></ApplicationService></ApplicationServiceList><LogSettings><LogFilter><!-- here you can enable tracing for ext activator --><TraceFlag>All Levels</TraceFlag><TraceFlag>All Modules</TraceFlag><TraceFlag>All Entities</TraceFlag></LogFilter></LogSettings></Activator>
To Test this i tried to push a message with the following script.
USE [Test] GO --DECLARE @data AS XML; --SET @data = (SELECT 'Hello' FOR XML PATH(''), ROOT('Changes'), ELEMENTS); DECLARE @data XML SELECT @data = N'<EVENT_INSTANCE><EventType>QUEUE_ACTIVATION</EventType><PostTime>' + CONVERT(CHAR(24),GETDATE(),126) + '</PostTime><SPID>' + CAST(@@SPID AS VARCHAR(9)) + '</SPID><ServerName>' + CAST(@@SERVERNAME AS VARCHAR(25)) + '</ServerName> -- use @@SERVERNAME to eliminate hard code<LoginName></LoginName> -- you can skip this element<UserName></UserName> -- you can skip this element<DatabaseName>' + CAST(DB_NAME() AS VARCHAR(20)) + '</DatabaseName> -- use DB_NAME() to eliminate hard code<SchemaName>dbo</SchemaName><ObjectName>TrackingRequestQueue</ObjectName><ObjectType>QUEUE</ObjectType></EVENT_INSTANCE>'; SELECT @data; DECLARE @handle AS UNIQUEIDENTIFIER; BEGIN DIALOG CONVERSATION @handle FROM SERVICE [TrackingInitiatorService] TO SERVICE 'TrackingTargetService' ON CONTRACT [TrackingContract] WITH ENCRYPTION = OFF; SEND ON CONVERSATION @handle MESSAGE TYPE [TrackingRequest] (@data)