Views: 4767
Number of votes: 0
Average rating:

Catch Monitoring Event inside CMS

Catch Monitoring Event inside CMS

With EPiSrever MirroringMonitoringModule you can easily catch monitoring events and build your application on it. The MirroringMonitoringModule is an http module that works as subscriber to the Monitoring server and caches monitoring events. The size of cache is by default 1000 per mirroring channel and it can be changed by mirroringMonitoringMaxDataPerJob attribute on sitesettings element. You can even listen on the Monitoring server status. Today there is already an Ajax application inside CMS which uses this module you can find it in Admin mode, Config, Mirroring, Mirroring Settings and Monitoring tab.

How can I access it by code?

Before go through the code you need configure Monitoring module and WCF Communication.
Add Monitoring module to webconfig file like

   1: <modules runAllManagedModulesForAllRequests="true">     
   2:      <add name="MonitoringModule" type="EPiServer.MirroringService.MirroringMonitoring.MirroringMonitoringModule, EPiServer.Enterprise"      preCondition="managedHandler"/> 
   3: </modules>


Add Client endpoint for Monitoring Server.

   1: <system.serviceModel>          
   2:     <client>
   3:      <endpoint
   4:          name = "mirroringMonitoringEndPoint" // The name should not be changed
   5:          address = "http://MirroringSite:port/MirroringMonitoringserver.svc"
   6:          binding = "wsDualHttpBinding" 
   7:          bindingConfiguration = "MonitoringMirroringBinding" 
   8:          contract = "EPiServer.MirroringService.MirroringMonitoring.IMirroringMonitoringEventSystem"/>     
   9:     </client>
  10:     <behaviors>
  11:       <serviceBehaviors>
  12:                   <behavior name="DebugServiceBehaviour">
  13:          <serviceDebug includeExceptionDetailInFaults="true" />
  14:        </behavior>
  15:       </serviceBehaviors>
  16:     </behaviors>
  17:     <bindings>
  18:      <wsDualHttpBinding>
  19:        <binding 
  20:             name="MonitoringMirroringBinding"        
  21:             maxReceivedMessageSize="20000000">
  22:               <security mode="None"/>
  23:        </binding>
  24:      </wsDualHttpBinding>
  25:     </bindings>
  26:   </system.serviceModel>

There are two static event handlers on the MirroringMonitoringModule module ServieConnectionEventHandler and MirroringTransferStatusEventHandler.
If you are interested on mirroring monitoring events you can use the MirrorngTransferStatusEventHandler. See code example blow.

   1: MirroringMonitoringModule.MirroringTransferStatusEventHandler += new MirroringStatusEventHandler(MyMonitoringEventHandler); 
   2: static MyMonitoringEventHandler(MirroringStatusEventArgs e)
   3: {    
   4:   // add code to process monitoring event 
   5: }

And If you like to know about the monitoring service status such as if the service is connected, disconnected or in error state. See the code example blow.

   1: MirroringMonitoringModule.ServiceConnectionEventHandler += new ServiceConnectionEventHandler(MyServiceConnectionEventHandler); 
   2: static MyServiceConnectionEventHandler() 
   3: { 
   4:   // Add code to handle monitoring server status 
   5: }


Apr 26, 2010

Please login to comment.