...
Edit variable
VarQuery
according to your database:For SQL Server:
Copy code
Code Block language sql CONCATconcat('SELECTselect * ,DATEDIFF_BIG(MILLISECOND, ',$apos,'19700101',$apos,', SYSDATETIMEOFFSET()) AS currentEpochTime from ABPM_TRIGGERS with(nolock)') concat('SELECT *, TIMESTAMPDIFF(MICROSECOND ',',', $apos,'1970-01-01 00:00:00',$apos,',',' SYSDATETIMEOFFSETNOW()) / 1000 AS currentEpochTime FROM ABPM_TRIGGERS WITH (NOLOCK)')
For Oracle:
Copy code
Code Block language sql CONCATconcat('SELECT a.*, (CAST(SYS_EXTRACT_UTC(SYSTIMESTAMP) AS DATE) - TO_DATE(',$apos,'1970-01-01'',$apos,$apos, ''YYYY-MM-DD',$apos,')) * 86400000 AS currentEpochTime FROM ABPM_TRIGGERS a');
For MySQL:
Copy code
Code Block language sql 'SELECT *, UNIX_TIMESTAMP(NOW()) * 1000 AS currentEpochTime FROM ABPM_TRIGGERS'
Step 7: Update Calendar Event to Run Flow Every 2 Hours
Navigate to
Configure > Event > Calendar Event
.Select the event
ADP_CE_eventMonitoringFlow
.Update the event to trigger every 2 hours.
Process Flow Activities Description:
Navigate to
Configure > Process flow > ADP_PF_EventMonitoringProcessFlow
Edit Process Flow
ADP_PF_EventMonitoringProcessFlow
.
...
This Process flow contains the following activities:
DataMapping - Mapping is This process will transform the event into an email to be dispatched as a notification.
...
DataMapping ForEach Description:
Code Block | ||
---|---|---|
| ||
$varExecuteQuery//Root/Record[(number(format-number(number(currentEpochTime ) - number( PREV_FIRE_TIME),'#')) > $varComparison and normalize-space(substring-after( TRIGGER_NAME,':' )) != '' and number(format-number(number(NEXT_FIRE_TIME ) - number( PREV_FIRE_TIME),'#')) < $varComparison) or (number(format-number(number(NEXT_FIRE_TIME ) - number( PREV_FIRE_TIME),'#')) > $varComparison and ((format-number(number(currentEpochTime ) - number( PREV_FIRE_TIME),'#') div format-number(number(NEXT_FIRE_TIME ) - number( PREV_FIRE_TIME),'#')) > (number($vargetMissFire) + 1)))] |
Target Layout :
...
Custom Plugin: For Email Notification
...
Custom code:
Code Block | ||
---|---|---|
| ||
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import com.adeptia.indigo.services.ServiceException; try { String hour = (String)context.get("hour"); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); StringBuffer sb = new StringBuffer(); sb.append("Hi,<br><br>This email is to notify you that some events have not been triggering for the past " + hour +" Hours.<br><br>The following events are currently stuck:<br><br>"); sb.append("<table \"width:70%\" border = \"1\">"); sb.append("<tr><th style=\"background-color:lightgrey;\">Event Name</th>" + "<th style=\"background-color:lightgrey;\">Last Fire Time</th>"+ "<th style=\"background-color:lightgrey;\">Action</th>"); sb.append("</tr>"); String line = reader.readLine(); while(line != null){ String []str=line.split(","); if(str.length != 0){ sb.append("<tr><td>"); sb.append(str[0]); sb.append("</td><td>"); sb.append(str[1] ); sb.append("</td><td>"); sb.append(str[2] ); sb.append("</td><td>"); sb.append("</tr>"); } line = reader.readLine(); } sb.append("</table>"); sb.append("<br>Thanks,<br>Adeptia Monitoring<br>"); // System.out.println(sb.toString()); service.write(sb.toString().getBytes(), "default"); }catch(Exception e) { e.printStackTrace(); throw new ServiceException(e); } |
Email Target :
...
Conclusion
Following these steps will allow you to successfully deploy and configure the Adeptia process flow for sending email notifications for stuck events. For further assistance, please reach out to the Adeptia support team.
...