Tuesday, January 21, 2020

Automatic scheduled publishing at intervals

Challenge:

So long back, I got a good amount of time to work on investing on how Scheduled publishing works.  Sitecore has implemented Scheduled publishing very well. But frankly as per my understanding it’s not yet ready to handle enterprise level requirements. But yeah agree that Sitecore guys has provided nice amount of API for everything using which you can extend their functionality which we also did 🙂

Solution:

So, here is my findings which will be useful for you guys as well!
Q. How to enable scheduled publishing?
Ans. By Default scheduled publishing is disabled and has following configuration inWeb.Config file
<!-- Agent to publish database periodically -->
<agent type="Sitecore.Tasks.PublishAgent" method="Run" interval="00:00:00">
<param desc="source database">master</param>
<param desc="target database">web</param>
<param desc="mode (full or incremental)">incremental</param>
<param desc="languages">en, da</param>
</agent>
Just a note : If interval’s value is 00:00:00 then it means that scheduler is disabled.
Now, to enable it just set the interval time and do the necessary settings as per your sitecore environment. E.g. If you have two publishing targets for example “web” and “dr-web
Then you need to do following configuration inWeb.Config
<!-- Agent to <span class="hiddenSpellError" pre="to ">publishWeb</span> database periodically -->
<agent type="Sitecore.Tasks.PublishAgent" method="Run" interval="00:00:30">
     <param desc="source database">master</param>
     <param desc="target database">web</param>
     <param desc="mode (full or incremental)">incremental</param>
     <param desc="languages">en, da</param>
</agent>
<!-- Agent to publish reading-web-farm database periodically -->
<agent type="Sitecore.Tasks.PublishAgent" method="Run" interval="00:00:30">
      <param desc="source database">master</param>
      <param desc="target database">dr-web</param>
      <param desc="mode (full or incremental)">incremental</param>
      <param desc="languages">en, da</param>
</agent>
Q. How scheduled publishing works?
Ans. During the work of the “Sitecore.Tasks.PublishAgent” all files that have been modified and have no publish restrictions will be published from the source database to the target database.
Publish restrictions are as below:
1. Item is not in final workflow state.
2. You selected “Never publish” at the “Publishing” section of the item.
NOTE: If you can’t see Publishing Section then enable Standard Fields from “VIEW” Tab.
3. You set publish restrictions at the “Restrictions” chunk in ribbon [Publish|Change Button in ribbon].
NOTE : The same functionality is provided by the fields at the “Publishing” and “Lifetime” sections
of the item.
Q.What does “Publishable To” field indicates?
Ans. It determines the date and time after which the item (the version of the item) will no longer be published to the target database (but will not be unpublished).
Q. I have provided all language options inWeb.Config. But can I do language wise publish?
Ans. Yes, you can set the restrictions for each version of the item in necessary language in the “Lifetime” section. Let’s say for an instance if you don’t want to publish German version of an item then set “Hide Version” from Lifetime section of an item.
Q. If I have two items to publish and both has same date time then how it will behave?
Ans. After the date and time that are specified in this field, the items will be published in order that is determined by dbo.PublishQueue table (incremental mode).
In smart mode the revisions from dbo.VersionedFields will be compared (revisions are determined by FieldID).
Happy Scheduled Publishing! 🙂

Worth to read:




Lifetime dates and workflow settings globally control which items are visible at various times. The most recent version of each language which has no publishing date, is not scheduled for future publication, does not have the Never publish checkbox selected in the Publishing section and in the Lifetime section has null dates or dates which surround the system date will be published. If an item’s parent is not published, then the item itself is not published - http://localhost/Company/AboutUs.html cannot exist without /company. Publishing can be further restricted to specific languages and/or publishing targets. With Sitecore the term Publish means to copy appropriate versions or entire items from the master to the web database accounting for these settings. See:
The frequency of scheduled publication can be manipulated, but note that publishing clears the HTML cache and therefore can interfere with performance. Review http://sdn.sitecore.net/SDN5/FAQ/Administration/Scheduled%20tasks.html and manipulate the Sitecore.Tasks.PublishAgent which is by default disabled by comments /web.config. Multiple entries may be required to support multiple languages.

 Prev Next 


https://doc.sitecore.com/SdnArchive/SDN5/FAQ/Administration/Scheduled%20tasks.html

https://www.techguilds.com/Blog/2018/11/scheduled-and-advanced-publishing-with-sitecore-part-2



No comments:

Post a Comment