November Happy Hour will be moved to Thursday December 5th.

Loading...
Area: Optimizely CMS
Applies to versions: 12 and higher
Other versions:
ARCHIVED This content is retired and no longer maintained. See the version selector for other versions of this topic.

Event management and event providers

Recommended reading 
Note: This documentation is for the preview version of the upcoming release of CMS 12/Commerce 14/Search & Navigation 14. Features included here might not be complete, and might be changed before becoming available in the public release. This documentation is provided for evaluation purposes only.

This topic describes the event management system and event providers in Optimizely. The events system provides a mechanism for distributing events between IIS applications and Optimizely websites in a load-balanced environment. The event system in Optimizely is provider-based, and you can either use the built-in event provider or develop your own customized one.

Event providers

An event provider, optimized for Microsoft Azure, is available on the NuGet feed. The event provider for Azure uses Service Bus for distributing events and requires no configuration of servers or network details. An event provider for Amazon Web Services also is available on the NuGet feed.

Customized event provider

Another alternative is to develop your own custom event provider, adapted for your hosting environment.

Configuring an event provider

To use another custom event provider, add the provider configuration to the appsettings.json. For example:

{
  "EPiServer" : {
    "Cms" : {
      "EventProviderOptions" : {
        "Provider" : "Custom Provider type"
      }
    }
  }
}

See Using the Event API for details.

Event system process flow

The following procedure describes the logical setup and execution of event system actions.

  1. When an Optimizely CMS website starts, it does the following:
    1. Creates a secret if one does not already exist in the site database.
    2. Initializes the Event Broker responsible for sending and recieving event messages remotely.
    3. Initializes each Event Provider that has been configured.
    4. Enables the Event system when the initialization process has completed (for example when CMS or Commerce has completed initialization).
  2. Code in a site obtains an Event object instance and subscribes to the Raised and optionally to the Missed event.
  3. Code in a site obtains an Event object instance and calls the Raise method (the Cache Manager could raise a cache changed event for example).
  4. The Event object instance fires the Raised event to notify the local subscribers.
  5. The Event object instance informs the Event Broker about the event.
  6. The Event Broker sends the event to all the other sites on the same server and other servers in the network using the configured Event Provider. In addition to the event information, a cryptographic HMAC block also is sent in the message to let the receiver test the authenticity of the event (this functionality can be disabled by the provider if a secure channel is already present).
  7. The Event Broker on another instance (either an IIS site on the local server or remote server) receives the sent message and does the following:
    1. Makes sure the message was sent from another instance sharing the same database. If no match is found, the action will be logged, the message dropped and no further action taken.
    2. Verifies the HMAC using the event data and the secret stored in the database (unless the provider disabled validation).
    3. If the verification fails, the action is logged, the message dropped, and no further action taken.
    4. Obtains the Event object instance for the event and calls the Raise method to notify the local subscribers.

Testing the event system

Examples of Optimizely CMS functionality that use the events system are Cache updates. To test cache events, edit a page on one Optimizely CMS site and ensure the change is reflected on the 2nd load-balanced Optimizely CMS website:

  1. On Optimizely CMS #1, navigate to a page in the example website.
  2. On Optimizely CMS #2, enter edit view and navigate to the same page as in step 1.
  3. On Optimizely CMS #2, add/edit/delete some text on the page and click Publish.
  4. On Optimizely CMS #1, refresh the page and ensure it reflects the new information saved in step 3.

Related topics

Do you find this information helpful? Please log in to provide feedback.

Last updated: Jul 02, 2021

Recommended reading