Wednesday, 17 April 2019

Add Publishing Targets in Sitecore 9.1


You are usually adding new publishing targets in Sitecore because of different geographic regions or databases in different data centers where you are hosting these web databases.

For a long time, for Sitecore 8, the process for creating a new publishing target was more or less the same. You have created a new entry in ConnectionStrings.config, added new <database> entry in web.config and added new definition item in master database under “/sitecore/system/Publishing targets” node.


In Sitecore 9 process has been slightly changed. You are not changing web.config anymore but Sitecore.config and 2 additional steps are now involved for adding a new publishing target. These two more steps are adding <eventQueue> and </PropertyStoreProvider> elements in Sitecore.config.

In my example below, I will use “Pub” as the name of the publishing target database. I will use “QA” as the name of the publishing target. In my example below, I will use “Pub” as the name of the publishing target database. I will use “QA” as the name of publishing target.

Steps to add new publishing target in Sitecore 9:Steps to add new publishing target in Sitecore 9:

  1. Create new target database in ConnectionStrings.config where you want content to be published:

    <add name="Pub" connectionString="Data Source=.\;Initial Catalog=webdbname;User ID=pubuser;Password=Password" />
  2. Add new entry in master database under “/sitecore/system/Publishing targets” node.



  3. Create a patch file under C:\inetpub\wwwroot\instancename\App_Config\Include\Project\ or any other folder based on your setup. I have named my patch config file “PublishingTargets.config” and this is it’s content (you can just copy it and change web_secondary based on name of your secondary web database specified in ConnectionStrings.config):



<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
     <sitecore>
         <eventing defaultProvider="sitecore">
            <eventQueueProvider defaultEventQueue="core">
                <eventQueue name="Pub" patch:after="eventQueue[@name='web']" type="Sitecore.Data.Eventing.$(database)EventQueue, Sitecore.Kernel">
                     <param ref="dataApis/dataApi[@name='$(database)']" param1="$(name)" />
                     <param hint="" ref="PropertyStoreProvider/store[@name='$(name)']" />
                </eventQueue>
            </eventQueueProvider>
         </eventing>
         <PropertyStoreProvider defaultStore="core">
             <store name="Pub" patch:after="store[@name='web']" prefix="Pub" getValueWithoutPrefix="true" singleInstance="true" type="Sitecore.Data.Properties.$(database)PropertyStore, Sitecore.Kernel">
                  <param ref="dataApis/dataApi[@name='$(database)']" param1="$(name)" />
                  <param resolve="true" type="Sitecore.Abstractions.BaseEventManager, Sitecore.Kernel" />
                  <param resolve="true" type="Sitecore.Abstractions.BaseCacheManager, Sitecore.Kernel" />
             </store>
         </PropertyStoreProvider>
         <databases>
         <!-- Pub -->
             <database id="Pub" patch:after="database[@id='web']" singleInstance="true" type="Sitecore.Data.DefaultDatabase, Sitecore.Kernel">
                 <param desc="name">$(id)</param>
                 <icon>Images/database_web.png</icon>
                 <securityEnabled>true</securityEnabled>
                 <dataProviders hint="list:AddDataProvider">
                     <dataProvider ref="dataProviders/main" param1="$(id)">
                         <disableGroup>publishing</disableGroup>
                         <prefetch hint="raw:AddPrefetch">
                              <sc.include file="/App_Config/Prefetch/Common.config" />
                              <sc.include file="/App_Config/Prefetch/Webdb.config" />
                         </prefetch>
                     </dataProvider>
                 </dataProviders>
                <PropertyStore ref="PropertyStoreProvider/store[@name='$(id)']" />
                    <remoteEvents.EventQueue>
                        <obj ref="eventing/eventQueueProvider/eventQueue[@name='$(id)']" />
                    </remoteEvents.EventQueue>
                    <archives hint="raw:AddArchive">
                        <archive name="archive" />
                        <archive name="recyclebin" />
                    </archives>
                    <cacheSizes hint="setting">
                         <data>100MB</data>
                         <items>50MB</items>
                         <paths>2500KB</paths>
                         <itempaths>50MB</itempaths>
                         <standardValues>2500KB</standardValues>
                    </cacheSizes>
              </database>
         </databases>
     </sitecore>
</configuration>


After applying these changes, you can see now pretty new publishing target in publishing dialogue in Sitecore 9:






No comments:

Post a Comment

Sitecore Publishing Service 7.0 Installation Guide

  About the Publishing Service module The Publishing Service module is an optional replacement for the existing Sitecore publishing methods....