I am seeking to inject a service with dependencies into a Marketing Automation Activity Type that will be instantiated by the Marketing Automation Engine.

I have successfully injected a basic service as per the docs, but the service I want to use has an existing IServicesConfigurator implementation:

public class ServiceBusConfigurator : IServicesConfigurator 
        public void Configure(IServiceCollection serviceCollection)
            serviceCollection.AddSingleton(typeof(IServiceBusQueueOptions<>), typeof(ServiceBusQueueOptions<>));
            serviceCollection.AddSingleton(typeof(IServiceBusTopicOptions<>), typeof(ServiceBusTopicOptions<>));
            serviceCollection.AddSingleton(typeof(IServiceBusQueue<>), typeof(ServiceBusQueue<>));
            serviceCollection.AddTransient(typeof(IServiceBusTopic<>), typeof(ServiceBusTopic<>));

            serviceCollection.AddTransient(typeof(IPublishJourneyStatusService), typeof(PublishJourneyStatusService));

The XML config for wiring up the dependency differs from the usual Sitecore pattern (see below) and I am unsure as to how to do this in the Automation Engine configuration.

                <Type>Foo.Foundation.MarketingAutomation.Services.PublishService, Foo.Foundation.MarketingAutomation</Type>
                <As>Foo.Foundation.MarketingAutomation.Services.IPublishService, Foo.Foundation.MarketingAutomation</As>

Is there a way to achieve this in either the engine XML configuration or in the Activity Type or even another injected service ?

Sitecore version is 9.1 initial release.

  • In theory, I should have been able to just wire up the other dependencies but that didn't work either. After a fair bit of experimentation, I think that the problem is with instantiating the generic types such as IServiceBusTopic<>, since other services work fine. – andyp May 16 '19 at 6:47
  • I've not had any problems with the xml config you listed before, but then I've not tried registering Generics. It's slightly different usecase, but in e.g. Autofac they allow config via xml (autofaccn.readthedocs.io/en/latest/configuration/xml.html) and suggest System.Diagnostics.Debug.WriteLine(typeof(IRepository<string>).AssemblyQualifiedName); to get the val you need in config file. – boro2g May 17 '19 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.