0

We have an event handler that publishes the certain type of pages to the different publications (we have the list of publications) and its working as expected but the problem here is the order in which it sends to the publishing queue. Yes it will send the pages as ordered in the list but the original tcm value in which we are only replacing the pub id is sent at the last of publicaition. For example when we send a page (tcm:5-1234-64)

EventSystem.Subscribe<RepositoryLocalObject, PublishEventArgs>(OnPageItemPre, EventPhases.Initiated);

private void OnPageItemPre(RepositoryLocalObject item, PublishEventArgs args, EventPhases phase){
    List <int>pubIDList = new List(){31,32,34,35};
    List<IdentifiableObject> itemToPublish = new List<IdentifiableObject>();
    foreach (var pubId in pubIdList)
    {
       itemToPublish.Add(item.Session.GetObject($"tcm:{pubId}-{pg.Id.ItemId}-64"));
    }
    
    PublishEngine.Publish(itemToPublish, args.PublishInstruction, publicationTargets, args.Priority.Value);
}

result: order in which the pages are published.

tcm:31-1234-64
tcm:32-1234-64
tcm:33-1234-64
tcm:34-1234-64
tcm:5-1234-64

how can we put tcm:5-1234-64 at the top of the queue?

9
  • Binod , just to clarify publication ID 5 is the parent and ( 31,32,33,34) or the child publication. – Anand NS Feb 25 at 15:24
  • You may try to utilize the priority feature here. Set the priority to high for parent publication (ID: 5) and for the rest, you can keep it normal. – Sayantan Basu Feb 25 at 15:24
  • @anandNS yes id 5 is the parent and ( 31,32,33,34) these the specific child publications – Binod Feb 25 at 15:34
  • @SayantanBasu you mean setting the priority in which it needs to send to the publishing queue? – Binod Feb 25 at 15:35
  • PublishEngine.Publish API - your last parameter you can control how you want to publish as @SayantanBasu mentioned, like PublishPriority.Normal or PublishPriority.High – Velmurugan Feb 25 at 15:36
2

The Publish Transactions you are adding in your event handler are before the original Publish Transaction, because your event handler triggers on the “Initiated” phase. That is: before the original Publish action executes.

If you want to add them after, you should subscribe to the “Processed” phase.

1
  • thanks @Rick its the perfect solution for me. – Binod Mar 1 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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