Introduction to Pipelines

Overview of Pipelines

A pipeline is a series of actions that execute in sequence to perform a task in Sitecore. Pipelines are fundamental to Sitecore's basic architecture. Most processes in Sitecore are defined as pipelines. Pipelines can be modified by developers to change, add, or remove functionality from Sitecore.

Pipelines are made up of one or more steps - called "processors." A pipeline is defind in configuration. For example, here is the definition for the getRenderingPreview from Sitecore.config:

	<processor type="Sitecore.Pipelines.GetRenderingPreview.GetXslRenderingPreview,Sitecore.Kernel" />
	<processor type="Sitecore.Pipelines.GetRenderingPreview.TryRenderControl,Sitecore.Kernel" />
	<processor type="Sitecore.Pipelines.GetRenderingPreview.GetRenderingPreviewField,Sitecore.Kernel" />
	<processor type="Sitecore.Pipelines.GetRenderingPreview.GetDefaultRenderingPreview,Sitecore.Kernel" />

When the getRenderingPreview pipeline is executed, the processors defined above run in order from first to last. Most pipelines pass data between each processor in the form of an arguments object. For example, getRenderingPreview use an arguments object called GetRenderingPreviewArgs. This stores data that each processor of the pipeline may need. This usually also includes data about the current Sitecore context.

A processor is implemented by a C# class. Many built-in pipelines can be found under the Sitecore.Pipelines namespace in Sitecore.Kernel.dll.

Call a Pipeline From Code

All pipelines must follow a convention and implement a Process() method, which must return void and must implement an arguments class based on Sitecore.Pipelines.PipelineArgs. For example:

public class MyPipelineProcessor
	public void Process(Sitecore.Pipelines.PipelineArgs args)
		// Your processor logic goes here

Once this pipeline is set up in configuration, it can be called elsewhere in code by using Sitecore's CorePipeline class:

Sitecore.Pipelines.CorePipeline.Run("myPipelineProcessor", new Sitecore.Pipelines.PipelineArgs());

Modifying Pipelines

Most pipelines are called as part of existing Sitecore processes and features. By adding or modifying processors to Sitecore's existing pipelines, developers can modify the core functionality of Sitecore.

Modifying an existing pipeline simply requires a processor and the appropriate configuration change. For example, here's the class for a new step in the PublishItemProcessor pipline:

namespace MyPublishProcessor
	public class PublishLogProcessor : PublishItemProcessor
		public override void Process(PublishItemContext context)
			if (context == null || context.Aborted)
			Sitecore.Diagnostics.Log.Info($"Item published: {context.ItemId.ToString()}");

Here's the configuration for that pipeline. We want to add this processor after the UpdateStatistics step:

<publishItem help="Processors should derive from Sitecore.Publishing.Pipelines.PublishItem.PublishItemProcessor">
	<processor type="Sitecore.Publishing.Pipelines.PublishItem.RaiseProcessingEvent, Sitecore.Kernel" />
	<processor type="Sitecore.Publishing.Pipelines.PublishItem.CheckVirtualItem, Sitecore.Kernel" />
	<processor type="Sitecore.Publishing.Pipelines.PublishItem.CheckSecurity, Sitecore.Kernel" />
	<processor type="Sitecore.Publishing.Pipelines.PublishItem.DetermineAction, Sitecore.Kernel" />
	<processor type="Sitecore.Publishing.Pipelines.PublishItem.MoveItems, Sitecore.Kernel" />
	<processor type="Sitecore.Publishing.Pipelines.PublishItem.PerformAction, Sitecore.Kernel" />
	<processor type="Sitecore.Publishing.Pipelines.PublishItem.AddItemReferences, Sitecore.Kernel" />
	<processor type="Sitecore.Publishing.Pipelines.PublishItem.RemoveUnknownChildren, Sitecore.Kernel" />
	<processor type="Sitecore.Publishing.Pipelines.PublishItem.RaiseProcessedEvent, Sitecore.Kernel" runIfAborted="true" />
	<processor type="Sitecore.Publishing.Pipelines.PublishItem.UpdateStatistics, Sitecore.Kernel" runIfAborted="true" />

And here's the configuration patch file to insert the custom processor to the pipeline:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="">
		<processor type="MyPublishProcessor.PublishLogProcessor, SitecoreDemo.Pipelines" patch:after="processor[@type='Sitecore.Publishing.Pipelines.PublishItem.UpdateStatistics, Sitecore.Kernel']" />