EventHub Events

EventHub overview

The EventHub helper class resolves the Sitefinity CMS event service. Event service is a mechanism that lets you easily subscribe to multiple events raised by the Sitefinity CMS modules and execute custom code when they are fired. The service provides a centralized entry point for working with a large collection of default Sitefinity events, as well as for creating custom events.

IEventService and EventHub

The Event Service is meant to be a central and uniform mechanism that allows event publishers/producers to talk to event subscribers/consumers. Its interface (IEventService) is a variation of the classic publish/subscribe pattern and the system implementation can be obtained by resolving the interface from the ObjectFactory.

C#
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Services.Events;

namespace SitefinityWebApp
{
   public class Global : System.Web.HttpApplication
   {
       protected void Application_Start(object sender, EventArgs e)
       {
           Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
       }

       private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
       {
           var eventService = ObjectFactory.Resolve<IEventService>();
       }
   }
}

Resolving the implementation this way allows its replacement with a custom one, in case this is needed. However, in most cases you can use the default implementation. To make the usage of the Event Service easier in the most common scenarios, the EventHubhelper class is introduced, which always resolves the event service implementation and lets it do the real work.

NOTE: You should be careful with custom code when subscribing to events from EventHub. Once the SiteSync is completed, you should be careful not to trigger the events later, as this will cause problems. For example, if you subscribe to the IDynamicContentUpdatedEvent, you must not republish the dynamic content item on the production environment, because this will trigger the event and could cause unexpected behavior.

This section contains

Work with EventHub events
Use the Event hub to subscribe and unsubscribe to events.
List of EventHub events
In this section, you can find a detailed list of the events exposed by Sitefinity CMS, grouped by the module or feature that exposes them.
Implement custom EventHub events
Apart from Sitefinity CMS default events raised by the built-in modules, you can create your custom events providing hooks to your code. In order to implement a custom event, you need to create an interface, a concrete implementation of the interface and raise the event.
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.