Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Learning Objective

  • Implement the deployment and configuration of the Adeptia process flow to enable the sending of email notifications for events that are stuck.

  • Guarantee prompt alerts for any events that are stuck to prevent delays.

  • Mitigate process flow deadlocks to ensure smooth operations.

Problem statement

In Adeptia, activating a Trigger in sequence for any event triggers the process flow or transaction sequentially. As a result, when a transaction enters a running state, the event will pause until the first process is completed. This scenario may result in a deadlock, where the event is awaiting the transaction to execute while the transaction is at a standstill. To mitigate this issue, a solution has been devised to send an email notification to the user, ensuring prompt awareness and resolution.

Introduction

This guide provides a detailed step-by-step process for deploying the Adeptia event monitoring process. This includes configuring backend database information, setting misfire and hour parameters, updating email credentials, and scheduling the calendar event for regular execution.

Prerequisites

Before you begin, ensure you have the following:

  • Adeptia Connect installed

  • Email server details

  • Backend database details

Solution

Step 1: Download Package ZIP

Step 2: Deploy Package Using Migration Utility

  1. Run MigrationUtility.exe.

image-20240723-101726.pngimage-20240723-101925.pngimage-20240723-102110.pngimage-20240723-102323.pngimage-20240723-102439.pngimage-20240723-102547.pngimage-20240723-102743.pngimage-20240723-102900.png

Step 3: Update Backend Database Credentials

  1. Navigate to Configure > Accounts > Database Info.

  2. Update the database configuration with the following details:

    • Database URL: jdbc:your_database_url

    • Username: your_db_username

    • Password: your_db_password

  3. Click on Test Database Connection and ensure the connection is successful.

image-20240723-103110.png

Step 4: Update Email Credentials

  1. Navigate to Configure > Target > Mail Target.

  2. Edit ADP_MD_sendEventDataInfo.

  3. Update the email server details with your SMTP server information.

  4. Update sender and receiver configuration in Mail Target.

Step 5: Set Miss Fire and Hour Parameter

  1. Go to the Process Flow section.

  2. Open ADP_PF_EventMonitoringProcessFlow.

  3. Set the Miss Fire parameter to the minimum time you want the event to misfire based on your requirement.

  4. Set the Hour parameter to the desired value (e.g., 2 if the event should be stuck for at least 2 hours).

Step 6: Update Database Query in Mapper

  1. Edit mapping ADP_DM_convertEventInfoToMail.

  1. Edit variable VarQuery according to your database:

    • For SQL Server:

      Copy code

      concat('select *,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,',',' NOW()) / 1000 AS currentEpochTime FROM ABPM_TRIGGERS')

      For Oracle:

      Copy code

      concat('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

       'SELECT *, UNIX_TIMESTAMP(NOW()) * 1000 AS currentEpochTime FROM ABPM_TRIGGERS

Step 7: Update Calendar Event to Run Flow Every 2 Hours

  1. Navigate to Configure > Event > Calendar Event.

  2. Select the event ADP_CE_eventMonitoringFlow.

  3. Update the event to trigger every 2 hours.

Process Flow Activities Description:

  1. Navigate to Configure > Process flow > ADP_PF_EventMonitoringProcessFlow

  2. Edit Process Flow ADP_PF_EventMonitoringProcessFlow.

image-20240724-054502.png

This Process flow contains the following activities:

  1. DataMapping - Mapping is This process will transform the event into an email to be dispatched as a notification.

image-20240724-052245.png

DataMapping ForEach Description:

$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)))]
  1. Target Layout :

image-20240724-052636.png
  1. Custom Plugin: For Email Notification

image-20240724-052747.png

Custom code:

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);
	}
  1. Email Target :

image-20240724-052955.png

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.

  • No labels