3

I'm using the PublishManager.Republish(...) to programmatically perform a full republish in a few Sitecore instances.

Since I need this operation to be synchronous, I'm calling the PublishManager.WaitFor(handle) method right after the previous one.

It works like a charm on Sitecore 8x and 9x.

But I can't understand why the waitFor is always returning false on my Sitecore 72 instance.

Did anyone face the same situation? Thanks in advance.

Edit: I'm using the types and methods present in Sitecore 7.2.151021 - Sitecore.Kernel.dll.

The handle returned by the Publish method is not null I can confirm here:

enter image description here

And I can confirm that the republish itself is being executed by seeing the newly created items on web database after a few seconds.

  • You mean you're using the Publishing Service? If so, that is only supported on 8.x and above. kb.sitecore.net/articles/545289 – Mark Cassidy Feb 28 '19 at 16:57
  • Hey Mark, I'm actually using the types and methods present in Sitecore.Kernel.7.2.151021, such as Sitecore.Publishing.PublishManager.Republish ()and then Sitecore.Publishing.PublishManager.WaitFor(). – Hugo Santos Feb 28 '19 at 18:39
  • @HugoSantos the issue is because the handle may be null. In the Sitecore 7.2 Kernel, it actually fetch the job based on the handle. So, the reason why it may return false is either the handle is null or when getting the job, it is being returned as null – Hishaam Namooya Feb 28 '19 at 18:53
  • @HishaamNamooya that was my first reflex too, but I can debug this code and the handle is not null. My point here is: Why the JobManager.GetJob(handle) would return null? It does not make sense to me and that's what I'm trying to figure out... Thanks anyway! – Hugo Santos Feb 28 '19 at 19:20
1

PublishManager in Sitecore 7.2 uses PublishStrategy mechanisms for publishing. It was deprecated in newer Sitecore versions.

PublishManager.Republish in the background calls its own Publish method with PublishMode.Full mode which then calls Publish method on PublishManager.PublishStrategy.

In not-scaled environment, with Event Queues disabled, default publish strategy is used, and standard job is added to JobsManager.

But when Settings.EnableEventQueues value is true, PublishManager.PublishStrategy property returns an object of RemotePublishStrategy type, which uses DistributedPublishingManager.QueuePublish and it doesn't use JobsManager but use StartPublishingRemoteEvent and the handle which is returned is a handle of that event, not a handle of a job queued in JobsManager.

One setting Settings.EnableEventQueues changes everything. Check your showconfig.aspx for the EventQueue.Enabled setting and if it's true, that's your answer.

| improve this answer | |
  • I can confirm that I have the EnableEventQueues = true. Thanks a lot Marek. So that means that if you are using event queues there is no way you can force sync behavior when calling the republish instead of an async? – Hugo Santos Mar 1 '19 at 12:18
  • 1
    I cannot tell this for sure as it's been ages since I last worked with 7.2. From what I see, there is no option with PublishManager directly, but you could try using new Sitecore.Publishing.Publisher(options).Publish(); instead. – Marek Musielak Mar 1 '19 at 12:27
0

It looks like it's a bug on the Sitecore 7.2 version.

By using DotPeek I can see that the way Sitecore handle the .WaitFor() method is completely different from Sitecore 7.x to later versions.

On Sitecore 7.2 it uses the JobManager.GetJob(handle) to check the state of the republish.

The issue here is that after I call PublishManager.Republish(...) there aren't any job on the JobManager.

Yeah, exactly.

JobManager.GetJobs() is returning an empty array.

That's why the PublishManager.WaitFor() is always returning false.

| improve this answer | |
  • Don't you use some RemotePublishingStrategy or other non-default implementation? I didn't debug the code but from what I can see, default publishing strategy calls JobManager.Start which adds new job to the _jobs list – Marek Musielak Feb 28 '19 at 19:46
  • Nops, I'm calling straight PublishManager.Republish() passing the master database and English language as parameter. And not only that but the publishing itself is working like a charm. It's the PublishManager.WaitFor() that is not doing its job properly. Thanks Marek! – Hugo Santos Feb 28 '19 at 20:00
  • 2
    Yes, but PublishManager.Republish calls PublishManager.PublishStrategy.Publish(options, clientLanguage);. And if Settings.EnableEventQueues value is true, RemotePublishStrategy is used instead of the default PublishStrategy. And it uses DistributedPublishingManager.QueuePublish which queues StartPublishingRemoteEvent instead of using JobManager. One setting Settings.EnableEventQueues changes everything :) – Marek Musielak Feb 28 '19 at 20:45

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.