cancel
Showing results for 
Search instead for 
Did you mean: 

Redwood Script for Raising Event for High Frequency Jobs

Gabie
Explorer
0 Kudos

Hello Experts,

This is in context with raising an event when the high frequency job fails 3 times consecutively in the last 24 hours. Kindly check and provide if there is any redwood script available for the same.

Thanks in Advance!

Accepted Solutions (0)

Answers (1)

Answers (1)

h_carpenter
Active Contributor
0 Kudos

Hi,

If you have the alerting module, also known as the active monitoring module, then you could easily specify a match for the process, in the alert action, you would check if there are more than two processes with status Error in the last 24 hours - if so, raise event.

Without the active monitoring module you would use a trigger that fires for processes from the definition in question reaching status Error; you check if there are two more processes in the last 24h from that process definition that failed and if so raise the event.

To get you started, look at:
Trigger example: https://docs.runmyjobs.cloud/9.2.8/TriggerExamples#solution-2
Query example: https://docs.runmyjobs.cloud/9.2.8/RedwoodScriptJobs/#count-the-number-of-processes-on-a-process-ser...

You would want something like this:

{
//Match the process to be used

if (JobDefintion of process matches the one I want)
{ 
  String query = "SELECT COUNT(*) FROM Job WHERE"
  + "Job.RequestedStartTimeInternal > now('subtract 24 hours') "  
  + "and Job.JobDefinition in "  
  + "(select JobDefinition.UniqueId from JobDefinition "
  + "where JobDefinition.MasterJobDefinition = ?) ";  

  LongCallBack callback = new LongCallBack(1);  
  try  
  {
    jcsSession.executeQuery(query, new Long[]  
    {  jcsJob.getJobDefinition().getMasterJobDefinition().getUniqueId()  }
     , callback);
  }
  catch (Exception e)
  {  throw new RuntimeException(e);  }
  Long myCount = (Long) callback.getResult().get(0);
  if (myCount != null)  {  jcsOut.println(myCount);  }
}
}

Regards,

HP'

Gabie
Explorer
0 Kudos

Thanks HP for guiding.