Marketing Automation plan processing

Current version: 9.2

The Marketing Automation Engine processes work items according to priority and processes items with a higher priority first.

Default xConnect plugin priority

By default, all work items added by the xConnect plugin use the priority configuration in the C:\path\toxconnect\App_data\config\sitecore\MarketingAutomation\sc.XConnect.Service.Plugins.MarketingAutomation.xml file. For example:

RequestResponse
<Settings>
<!--
    Configuration for the Marketing Automation plugin for XConnect.
-->
<Sitecore>
    <XConnect>
                    <MarketingAutomation>
                            <XConnect>
                                    <Services>
                                            <!-- An XConnect plugin which queues Marketing Automation work in the Automation Pool. -->
                                            <XConnect.Service.Plugins.MarketingAutomation.XdbContactEventWatcher>
                                                    <Type>Sitecore.XConnect.Service.Plugins.MarketingAutomation.XdbContactEventWatcher, Sitecore.XConnect.Service.Plugins.MarketingAutomation</Type>
                                                    <As>Sitecore.XConnect.Service.Plugins.IXConnectServicePlugin, Sitecore.XConnect.Service.Plugins</As>
                                                    <LifeTime>Singleton</LifeTime>
                                                    <Options>
                                                            <!-- The default priority to set on new work items in the Automation Pool.
                                                            Default: 80
                                                            -->
                                                            <DefaultPriority>80</DefaultPriority>
                                                    </Options>
                                            </XConnect.Service.Plugins.MarketingAutomation.XdbContactEventWatcher>
                                    </Services>
                            </XConnect>
                    </MarketingAutomation>
    </XConnect>
</Sitecore>
</Settings>

Prioritize work from a particular channel

To vary prioritization based on the properties of an interaction, you must replace the default xConnect plugin that adds work items to the Marketing Automation pool. To create your own plugin:

  1. Create a class that inherits Sitecore.XConnect.Service.Plugins.MarketingAutomation.XdbContactEventWatcher (the default xConnect service plugin).

  2. Override the .GetPriority() method with your own logic. For example, you may want to prioritize work coming from a specific interaction channel.

  3. Open the C:\path\toxconnect\App_data\config\sitecore\MarketingAutomation\sc.XConnect.Service.Plugins.MarketingAutomation.xml file and replace the following line with your own plugin:

RequestResponse
<Type>Sitecore.XConnect.Service.Plugins.MarketingAutomation.XdbContactEventWatcher, Sitecore.XConnect.Service.Plugins.MarketingAutomation</Type>

The following example shows a derived plugin that sets the priority to its highest value if the interaction comes from a social channel:

RequestResponse
public class SocialHighPriorityPlugin : XdbContactEventWatcher
{
    private Guid SocialMentionsChannelId = Guid.Parse("{5C56C3CD-6BAB-4EAB-ACF4-C30464326C05}");

    public SocialHighPriorityPlugin(
        IConfiguration configuration,
        IAutomationPool pool,
        IActivityEnrollmentProvider activityEnrollmentProvider,
        ILogger<SocialHighPriorityPlugin> logger)
        : base(configuration, pool, activityEnrollmentProvider, logger)
    {
    }

    public SocialHighPriorityPlugin(
        IAutomationPool pool,
        IActivityEnrollmentProvider activityEnrollmentProvider,
        ILogger<SocialHighPriorityPlugin> logger,
        byte defaultPriority)
        : base(pool, activityEnrollmentProvider, logger, defaultPriority)
    {
    }

    protected override byte GetPriority(Interaction interaction)
    {
        if (interaction.ChannelId == SocialMentionsChannelId)
            return 255;

        return base.GetPriority(interaction);
    }
}

Configure pool workers

The Marketing Automation Engine adds pool workers automatically, so you do not have to define each pool worker individually (although it is also possible to do this if you need to). You can specify how many high, normal, and low priority pool workers you create, and you can set a number of parameters for the workers that have each of these priorities.

You configure pool workers in the \App_data\config\sitecore\MarketingAutomationsc.MarketingAutomation.Workers.xml file. The PoolWorker.Configurator node has settings for the automatically created pool workers.

The WorkerToCoreRatio setting specifies how many total workers are created as a ratio of the number of CPU cores reported by the OS. With a ratio of 1, as many workers will be created as there are cores (so if the OS reports 8 cores, 8 workers total will be created). If the ratio is 0.5, then on an 8 core machine only 4 workers will be created.

You can control the number of high, normal, and low priority workers created with the HighPriorityWorkerRatio and NormalPriorityWorkerRatio settings.

HighPriorityWorkerRatio specifies the ratio of high priority workers created out of the total workers created. If 8 workers are created and this setting is 0.25, then 25% of the workers will be high priority (in this case 2). NormalPriorityWorkerRatio specifies the number of normal priority workers in the same way: a setting of 0.5 means that half the total workers created will be normal priority workers. There is not a setting for low priority workers as this number can be calculated from the other other two settings. However, one low priority worker is always created.

You can specify a number of settings for the workers created with each priority, including:

Setting

Description

Schedule

Specifies how long the workers sleep when there is no work available (in seconds)

MinimumPriority

Specifies the minimum priority of work items to process

WorkItemTimeout

Specifies hours:minutes:seconds of timeout for a work item

WorkItemTimeoutSchedule

Specifies hours:minutes:seconds before the timeout is reset

It is possible to create individual pool workers and set the same parameters for each worker:

RequestResponse
<ExplicitPoolWorker1>
    <Type>Sitecore.Xdb.MarketingAutomation.Processing.PoolWorker, Sitecore.Xdb.MarketingAutomation</Type>
    <As>Sitecore.Xdb.MarketingAutomation.Core.Processing.IPoolWorker, Sitecore.Xdb.MarketingAutomation.Core</As>
    <LifeTime>Transient</LifeTime>
    <Options>
        <Schedule>00:00:20</Schedule>
        <MinimumPriority>0</MinimumPriority>
        <WorkItemTimeout>00:00:10</WorkItemTimeout>
        <WorkItemTimeoutSchedule>00:00:07</WorkItemTimeoutSchedule>
        <BatchHead>3</BatchHead>
        <BatchSize>5</BatchSize>
    </Options>
</ExplicitPoolWorker1>

Stalling work items

Processing of a work item can fail for a number of reasons. The engine will retry processing after a short period of time, but there are situations where the work item can never be processed (for example, if a plan has been deleted). To avoid wasting resources by retrying repeatedly, items are stalled (moved to a special pool) after a number of retries, and they are not retried again.

You specify when work items are stalled in the \App_data\config\sitecoreMarketingAutomationsc.MarketingAutomation.PoolFilter.xml file.

In the MarketingAutomation.AttemptLimitWorkItemRegulator node, you can set the number of retries to attempt before stalling a work item (the AttemptLimit setting).The default is 100.

In the MarketingAutomation.AgeLimitWorkItemRegulator node, you can set a time limit for retries. Once that much time has passed since the work item was initially created, processing will not be retried again. The setting is AgeLimit and the default value is 10.00:00:00, which is 10 days.

Do you have some feedback for us?

If you have suggestions for improving this article,