Commands

Some points to be kept in mind while working with Timer Job:

I have been working with timer job since a long time and I have listed some points that one needs to keep in mind while working on it.

The following are some of the points that we need to keep in mind:

  • In order to consume a wcf service in timer job, we need to add an endpoint in the owstimer.exe.config file of the web application.
  • owstimer.exe.config is the config file for timer jobs. It is very similar to the web.config for the web applications.
  • One can declare the global variables for multiple timer jobs over here like one does in the web.config file.
  • The owstimer.exe.config is located at the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\BIN location.
  • It is advisable to save a backup of this file before making any changes to it so that if one messes up the file we can recover it from the backup.
  • The following is the code to be added in the file:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled=”true” />
<bindings>
<basicHttpBinding>
<binding name=”BasicHttpBinding_Iapi” closeTimeout=”00:01:00″ openTimeout=”00:01:00″ receiveTimeout=”00:10:00″ sendTimeout=”00:01:00″ allowCookies=”false” bypassProxyOnLocal=”false” hostNameComparisonMode=”StrongWildcard” maxBufferSize=”2147483647″ maxBufferPoolSize=”2147483647″ maxReceivedMessageSize=”2147483647″ messageEncoding=”Text” textEncoding=”utf-8″ transferMode=”Buffered” useDefaultWebProxy=”true”>
<readerQuotas maxDepth=”32″ maxStringContentLength=”8192″ maxArrayLength=”16384″ maxBytesPerRead=”4096″ maxNameTableCharCount=”16384″ />
<security mode=”None”>
<transport clientCredentialType=”None” proxyCredentialType=”None” realm=”” />
<message clientCredentialType=”UserName” algorithmSuite=”Default” />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address=”url” binding=”basicHttpBinding” bindingConfiguration=”BasicHttpBinding_Iapi” contract=”ContractName.Iapi” name=”BasicHttpBinding_Iapi” />
<endpoint address=”url” binding=”basicHttpBinding” bindingConfiguration=”BasicHttpBinding_Iapi” contract=”WCFServiceReference.Iapi” name=”BasicHttpBinding_Iapi” />
</client>
</system.serviceModel>

  • Add the <system.serviceModel> tag after the <runtime>.
  • Here contract name is the name of the namespace that is obtained from the app.config file of the timer job.
  • In order to add multiple end points, add the tag as per requirement.
  • Always set the scope to Web Application.
  • Many a times during the deployment we encounter an error where we are told to force the deployment. For that we need to add the AlwaysForceInstall=”TRUE” in Manifest.xml file
  • The file looks something like the one shown below:

<?xml version=”1.0″ encoding=”utf-8″ ?>
<Feature xmlns=”http://schemas.microsoft.com/sharepoint/&#8221;
AlwaysForceInstall=”TRUE” >
</Feature>

 

 

Leave a comment