Publishing is at the heart of every Tridion implementation – and when it breaks, I feel a bit sad inside.  Recently I had a strange content scenario breaking the Publisher service (and the TcmServiceHost.exe in Preview).  This happens about 1 time every 2 weeks or so, but when it does, it’s painful.  A seemingly normal Multimedia Component could cause this to happen, and we had no way to predict it.

Scenario:

1.  Publishing a Multimedia Component (linked to Page) gets stuck at the ‘Rendering’ phase and will not continue or fail.
2.  All other pages after this remain waiting in the Publish Queue.

To fix it:

1.  Remove item from Publish Queue
2.  Re-start Publisher

Troubleshooting the problem:
1.  Remove the Multimedia Components 1 by 1 until the problem one is found.
2.  Create a new Multimedia Component, using the same image, and replace the old broken Multimedia Component
3.  Re-Publish

We are still looking for the root cause.

In the meantime, we need a way to make sure the Publish Queue does not get stuck.

The Solution

Create a Windows Service that scans the Publish Queue at a regular interval (ie. 5 minutes) and if an item is in Queue for 2 intervals at the same phase, it’s stuck.  Remove the stuck item from the Queue, restart the Publisher service, and email an Admin.

Source Code

The Source Code is on GitHub at https://github.com/rcurlette/TridionPubQMonitor

Main class:  https://github.com/rcurlette/TridionPubQMonitor/blob/master/TridionPubQMonitoringService/TridionPubQService.cs

To Run:
1.  Download Source Code
2.  Add the Tridion Core Service DLL and Config to dependencies folder
3.  Update the app.config with your username / password for the Core Service
4.  Add mailtrap.io settings for sample email
5.  Compile
6.  Open Command Prompt (Run As Admin)
7.  Run ‘InstallUtil.exe TridionPubQMonitoringService.exe’
You can run this on the .exe file built from your Visual Studio in the bin/Debug folder
8.  Start the Service in the Services Control Panel.  Look at the Tridion Event Log for messages about starting, stopping, etc
9.  To recompile, stop the service, uninstall it ‘InstallUtil.exe /u TridionPubQMonitoringService.exe’ and then compile and install

Tips:

– Change the Phase to a phase that items stay in for more than 5 minutes while testing.  I had a lot of pages going to ‘Failed’ on my local Dev box, so I set it to that phase.  But if your Dev server is in better shape than mine, maybe you would want to change that to ‘Success’.

– You should see the items disappear from the Publish Queue at some moment (after 2 time intervals have passed) and also a message written to the Tridion Event Log.

 

Site labels and other resource strings are something we can manage in Tridion and the SDL Tridion Reference Implementation (STRI) also allows us to manage these key/value pairs in 2 ways.  The sample website uses a dedicated Schema for the resources and hardcodes fieldname / fieldvalue in the Schema.  The other way is to create a classic config Schema with a multi-value embedded key/value pair Schema.

Updating the existing labels

In the CMS you can find the example resource strings in the Component located at ‘\100 Master\Building Blocks\Settings\Core\Site Manager’. To add a new resouce string, we should edit the Schema and add an additional field to the Schema.

How do we use the existing resource strings in the MVC app?

The Place HTML View has a good example: ‘…\tri-master\web-application\Site\Areas\Core\Views\Entity\Place.cshtml’

@Html.Resource("core.teleponeCaptionText")

Publishing the Resource Strings

And after we change the value of a setting or resource string we need to publish the Page ‘\400 Exmaple Site\Home\_System\Publish Settings’.

The Resource string Component is linked to our ‘Core’ settings Component here: ‘\100 Master\Building Blocks\Modules\Core\Admin\Core’

Creating a new Label set

Creating a new label set is quite easy and also already documented here:
However, for me I wanted to add this to the existing STRI demo site, and that was not 100% clear. Here is how I did it:

  1. Create a Folder ‘Building Blocks/Settings/MySite/Site Manager’
  2. Create a Component using the ‘General Configuration’ Schema. The ‘Configuration Name’ field is not used.
  3. Link the new Labels Component from the step above to ‘\100 Master\Building Blocks\Modules\Core\Admin\Core’ in the Resources field.
  4. Publish the ‘Publish Settings’ page here ‘\100 Master\Home\_System’
  5. Display the label in a View, for example the Article view here ‘…\tri-master\web-application\site\areas\core\views\entity\article.cshtml’
    @Html.Resource("core.contactUs")

The ‘core’ here refers to the ‘Module name’ of the ‘Module Configuration’ Component at ‘\100 Master\Building Blocks\Modules\Core\Admin’ and the Module name is taken from the Path of the Component. It is also the Module in the Publish Settings Page.

The ‘contactUs’ is the Key of our label.

6. Refresh the Web app going to the ‘http://localhost:59860/admin/refresh’ and see the new Label