Showing posts with label Other. Show all posts
Showing posts with label Other. Show all posts

February 6, 2012

Remote events how to investigate

I had some issues with the sitecore remote events not triggered on the content delivery. I will explain how you can investigate why it could happened and how to fix it.


First of all, how sitecore handle the remote events when you use the scalability?


When you publish an item in sitecore, sitecore will write a line in the EventQueue table of the corresponding database with all the necessary data including the InstanceName of the server who have triggered the event.

After that sitecore have an timer who check in this table if they are any event to trigger. First remark, sitecore look at the InstanceName field to know if this instance need to trigger this record or not so this instance need to be unique (be carefull with the copy paste) ;-).


Here is what sitecore add in the web database in the EventQueue when you publish an item:
Id 82480059-8CF4-4D2E-82B1-9C00323F12F2
EventType Sitecore.Eventing.Remote.PublishEndRemoteEvent, Sitecore.Kernel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null
InstanceType Sitecore.Eventing.Remote.PublishEndRemoteEvent, Sitecore.Kernel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null
InstanceData {"CompareRevisions":true,"Deep":false,"FromDate":"\/Date(-5339901827822+0200)\/","LanguageName":"en","Mode":3,"PublishDate":"\/Date(1328532964271+0100)\/","PublishingTargets":["{8E080626-DDC3-4EF4-A1D1-F0BE4A200254}","{8E080626-DDC3-4EF4-A1D1-F0BE4A200254}"],"RepublishAll":false,"RootItemId":"ebff6e2a-9149-4660-9d55-dec34282f856","SourceDatabaseName":"master","TargetDatabaseName":"web"}
InstanceName GRNQ6R1-sitecore650up3
RaiseLocally 0
RaiseGlobally 1
UserName sitecore\admin
Stamp 0x0000000000079C0F
Created 2012-02-06 12:56:07.033


The most important columns are :
  • "InstanceName": it is the server who have triggered the event. (setting "InstanceName" from ScalabilitySettings.config)
  • "EventType": The type of event: item:saved:remote, publish:end:remote, ...
  • "InstanceData": The data required to perform this operation

This is the first method to see if your events are trigered.

For the second method, you need to set in the web.config of each server the <events timingLevel="high"> setting (this setting is set to custom by default).
With this modification you should have any line like this for each event handled by sitecore in your log on both content delivery and content management instances.
Heartbeat 14:22:05 INFO  Event started: publish:statusUpdated
Heartbeat 14:22:05 INFO  Executed: Sitecore.Publishing.RemotePublishingEventHandler.OnStatusUpdated(). Elapsed: 4,23265309264199
Heartbeat 14:22:05 INFO  Event ended: publish:statusUpdated. Elapsed: 4,33442834380877

If even with all those informations your events are not triggered or triggered but not received in by the other server you can try to cleanup the temporary event tables.
On each database execute those scripts:
DELETE FROM EventQueue;
DELETE FROM [Properties] WHERE  [Key] LIKE 'EQStamp%';

I don't know exactly what is the EQStamp% setting but it was the solution provided by the support and it has solved my problem :) If anybody know what is is exactly you can post a comment.

Be also careful to the exception in your events because if one event of the pipeline throw an exception the other one will be not executed.

April 28, 2011

Infinite loop when using sitecore and the iis url rewriting

Recently I have install the ULRewrite module for IIS7 : http://www.iis.net/download/URLRewrite

Everything was good but during my tests with IE7 I had a strange comportment: I have an infinite loop on the error page.

In fact, it was a mistake during the configuration of this module. Effectively, this module add this section in the web.config.
<httpErrors>
  <remove statusCode="404" subStatusCode="-1" />
  <error statusCode="404" prefixLanguageFilePath="" path="/notfound" responseMode="ExecuteURL" />
 </httpErrors>
</system.webServer>
But the error page I have configured as the ItemNotFoundUrl is error-page-not-found.aspx:
<setting name="ItemNotFoundUrl" value="/sitecore/service/error-page-not-found.aspx" />
So we only need to put this url of our custom error page in path="XXX” or simply remove the section <httpErrors>

February 17, 2011

Adding custom icons for the media library

If you need to have some custom icons in the media library you have several options:
  • Install the corresponding program on the computer and associate the file with this program (ie: acrobat reader for .pdf files). This option is maybe not an option for the production server.
  • Associate the file extension in the operating system. Open "Control Panel -> Folder Options-> File Types -> New -> Add file Extension" then register the icon for this extension (Advanced -> Change Icon)
  • Associate the Icon with the file extension in your web.config. Add thumbnails generator for the known file type. For example for PDF file type:
    <mediaType name="PDF file" extensions="pdf">
      <mimeType>application/pdf</mimeType>
      <forceDownload>false</forceDownload>
      <sharedTemplate>system/media/unversioned/pdf</sharedTemplate>
      <versionedTemplate>system/media/versioned/pdf</versionedTemplate>
      <thumbnails>
        <generator type="Sitecore.Resources.Media.MediaThumbnailGenerator, Sitecore.Kernel">
          <extension>png</extension>
        </generator>
        <staticFile>Path where the icon is located. For example /sitecore/shell/Themes/standard/images/pdf_icon.png</staticFile>
      </thumbnails>
    </mediaType>
    

After these modification, clear the cached files:
  1. Open the folder "/Temp" under the Sitecore root.
  2. Delete all files with the name "fileicon.....".
  3. Clear media cache "/App_Data/MediaCache" under the Sitecore root.

January 3, 2011

Sitecore Visual Studio Templates

I have just found some templates for visual studio with all the think you can create for sitecore in the project http://trac.sitecore.net/SitecoreStuff

To install them you may:
Either
  • download the project: http://trac.sitecore.net/SitecoreStuff 
  • unzip it 
  • Open the folder "Visual Studio Templates"
  • Modify the install2008.cmd file if you have visual studio 2010 (if you use VS2008 it is already ok)
  • Execute it
  • Restart Visual Studio
 Or
Or
    • Install Sitecore Rocks (Thank you Lars Nielsen for this tips)
    Now you should have something like this when you add a item in visual studio:

    Thank you the creators of those templates!

    November 29, 2010

    XPath Query - Perform a case insensitive comparison

    To perform a case insensitive comparison you may use the function : CompareCaseInsensitive.

    Example:
    /sitecore/content//*[CompareCaseInsensitive(@@myfield,'MyValue')]


    If you need to compare the field 'name' case insensitively you may use 'key' in place of 'name'.
    Example:
    /sitecore/content//*[@@key,'myvalue')]


    Important: the search value has to be lower case!


    All the XPath query function are available in Sitecore.Data.Query.Functions