I have a requirement to invalidate the file in cdn cache on completion of sitecore item publishing. To achieve this I have created custom processor and patched into "publishEndResultBatch" pipeline, my patches are displaying in showconfig. But the code is not triggered, I have debugged and added logs, no symbol to trigger this processor.

I have even created custom event handler and patched in "publishingservice:publishend" event. This is also not triggered.

No issue in item publish.

Is it need any additional settings to use the custom events or processor in sitecore publishing service?

Below are the package details,

  • Instance
    • Sitecore 9 update 1
  • Sitecore Publishing Service
    • Sitecore Publishing Module 3.1.1 rev. 180807.zip
    • Sitecore Publishing Service 3.1.1 rev. 180807-x64.zip

Below are the code snippet

Custom processor:

public class CustomPublishEndResultBatch
    Log4NetLogger _logger = new Log4NetLogger();
    public void Process(PublishEndResultBatchArgs args)
        _logger.Log("publishEndResult Batch", EnumUtil.LoggingType.Info, EnumUtil.ExceptionTier.PublishingService, null);

            if (args.TotalResultCount >= 1)
                Guid filePathFieldGuid = new Guid("{2134867A-AC67-4DAC-836C-A9264FD9D6D6}");
                var affectedItem = args.Batch.Select(b => b.EntityId).Distinct().Count();
                var modifiedMediaItems = args.Batch.Where(b => b.Type == ManifestOperationResultType.Modified && b.EntityType == ManifestEntityType.Media).Select(b => b.Metadata).Distinct().ToList();
                var pdfItems = modifiedMediaItems.Select(b => b.FieldChanges.Where(x => x.FieldId == filePathFieldGuid && x.Value.ToLower().Contains(".pdf")).Any()).ToList();
        catch (Exception ex)
            _logger.Log("PublishEndResultProcessor is failed", EnumUtil.LoggingType.Error, EnumUtil.ExceptionTier.PublishingService, ex);



Custom Event :

public class CustomPublishEndHandler
    public void OnItemPublished(object sender, EventArgs args)
        List<string> publishedIds = new List<string>();
        ILogger _logger = new Log4NetLogger();
        _logger.Log("Custom Publish end event", EnumUtil.LoggingType.Info,EnumUtil.ExceptionTier.UserProfileService, null);

        var itemArgs = args as ItemProcessedEventArgs;

        if (itemArgs != null && !ID.IsNullOrEmpty(itemArgs?.Context?.ItemId))


    public void GetPDFItemPath(ID processedItem)
        //TODO: Change this step
        var item = Factory.GetDatabase("master").Items.GetItem(processedItem);

        if (item != null && item.TemplateID == Sitecore.Data.ID.Parse("{0603F166-35B8-469F-8123-E8D87BEDC171}"))
            var thread = new Thread(() => CdnFileInvalidationHelper.InvalidateContent(item.Paths.FullPath));
            thread.IsBackground = true;

Note - This custom event is working fine when adding into normal sitecore publishing event "publish:itemProcessed"

Configuration Entries:

<event name="publishingservice:publishend" patch:source="Sitecore.Publishing.Service.config">
<handler type="Sitecore.Publishing.Service.Events.PublishingJobEndHandler, Sitecore.Publishing.Service" method="StartPublishEndPipeline">
    <param name="manifestResultLoadBatchSize">500</param>
<handler type="Sitecore.Publishing.Service.Events.PublishEndHandler, Sitecore.Publishing.Service" method="TriggerPublishEnd"/>
<handler type="AllianzGI.DEXTER.Web.Extensions.Events.CustomPublishEndHandler, AllianzGI.DEXTER.Web.Extensions" method="OnItemPublished"/>

<publishEndResultBatch argsType="Sitecore.Publishing.Service.Pipelines.BulkPublishingEnd.PublishEndResultBatchArgs" patch:source="Sitecore.Publishing.Service.config">
<processor type="Sitecore.Publishing.Service.Pipelines.BulkPublishingEnd.RaiseRemoteEvents, Sitecore.Publishing.Service">
<param name="remoteEventCacheClearingThreshold">1000</param>
<param name="targetCacheClearHistory" ref="publishing.service/targetCacheClearHistory"/>
<processor type="AllianzGI.DEXTER.Web.Extensions.Pipelines.CustomPublishEndResultBatch, AllianzGI.DEXTER.Web.Extensions"/>

  • Are you able to share your code? – Anicho Feb 14 '19 at 8:52
  • @Anicho, Added the code snippet in the question – Thenmozhi Subramaniam Feb 14 '19 at 9:39
  • Can you please add your config entries as well.. – Gobinath Saminathan Feb 14 '19 at 16:01
  • @Gobinath, Added configuration details here, please check and let me know your point, it will be helpful. – Thenmozhi Subramaniam Feb 20 '19 at 5:57
  • @ThenmozhiSubramaniam if you place your handler namespace in the Sitecore Event publish:end and publish:end:remote does it work? Also, check your publishing logs for any errors – Hishaam Namooya Feb 20 '19 at 7:19

If I understand your requirement correct then you just want to invoke your custom code during the "publishingservice:publishend". So you can add a handler in the event "publishingservice:publishend", something like the below.

Added the below patch in the "App_Config\Include" folder. [give a name on your own z.anything.config, i always prefer adding a patch instead of editing the Sitecore's original config files/entries]

    <event name="publishingservice:publishend">
      <handler type="Portal.Poc.Foundation.CustomPublisher, Portal.Poc.Foundation" method="DoCustomCode"/>

And the Code is,

using Sitecore.Diagnostics;
using System;
namespace Portal.Poc.Foundation
    public class CustomPublisher
        public CustomPublisher()
        public void DoCustomCode(object sender, EventArgs args)
            Log.Info("You are in custom Publish End Handler", "PublishEnd");

The above code is executed whenever an item publish is invoked, tested by putting a breakpoint as well as the above log is written in the log file.

Note - This is tested in the same version of Sitecore and Publish Module & Service you mentioned in the above.

The class PublishingJobEndHandler in the event "publishingservice:publishend" invokes the "publishEndResultBatch" pipeline. So I guess if you want to implement a processor then you can customize/extend the existing or you can create your own pipeline and invoke the same from your custom handler which you are going to add in the "publishingservice:publishend".

Hope this helps.

  • I have used the same step still it's not triggering, but items are published and publishing service has the log of the item but custom publish log is not there in sitecore. – Thenmozhi Subramaniam Feb 21 '19 at 10:00
  • @ThenmozhiSubramaniam Is there any custom config added in your code or customized the publish module or service.? also can you please check the sitecore log for any errors.? – Gobinath Saminathan Feb 21 '19 at 14:54

This issue is resolved by removing the unused configuration file. In our instance, there was a backup folder which contains the configuration file, which blocked the custom event handler on publishing service.

  • Hi....How did you resolve this error? as i am also not ablt to hit any breakpoint and debug in my local? – Sreekrishnan Nov 3 '20 at 7:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.