<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Can we monitor ivy process programmatically?</title><link>https://answers.axonivy.com/questions/2244/can-we-monitor-ivy-process-programmatically</link><description>&lt;p&gt;Hi all&lt;/p&gt;
&lt;p&gt;i have a sample callable subprocess as below:
&lt;img alt="alt text" src="http://answers.axonivy.com/upfiles/Untitled_ifhSuXB.png"&gt;&lt;/p&gt;
&lt;p&gt;With SubProcessCall util, i can trigger to run it and also control input&amp;amp;output. So i want to go a step futher to monitor that such process. Is there any API or util that could help me to monitor this process? like when process come to step &lt;em&gt;Do first thing&lt;/em&gt;, i will be notified and i can access variable &lt;strong&gt;in/out&lt;/strong&gt; or just simple logging out the name of that ivy element.? Also the same question for other kind of process (sub process/start process/...)&lt;/p&gt;
&lt;p&gt;Thanks all&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/2244/can-we-monitor-ivy-process-programmatically" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 06 Dec 2016 12:51:03 -0500</lastBuildDate><item><title>Answer by Reguel Wermelinger</title><link>https://answers.axonivy.com/questions/2244/can-we-monitor-ivy-process-programmatically/2246</link><description>&lt;p&gt;Should be an easy task with process engine of 6.0 and upwards. Be aware that the shown example uses non-public API and that it can change without any notice.&lt;/p&gt;
&lt;p&gt;The following code show a custom engine execution listener that logs the data and process element PID of every element that is executed:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public class ExecListener {

    public static void install()
    {
        IBpmEngine engine = DiCore.getGlobalInjector().getInstance(IBpmEngine.class);
        engine.getHistory().addElementHistoryListener(new LoggingListener(Ivy.log()));
    }

    private static class LoggingListener implements IElementHistoryListener
    {
        private final Logger logger;

        public LoggingListener(Logger logger) {
            this.logger = logger;
        }

        @Override
        public void elementExecutionHistoryAdded(IElementExecutionHistory executionHistory) {
            PID pid = executionHistory.getElementRequestHistory().getElementHistory().getProcessElementId();
            logger.info("executing element pid: "+pid);

            Object in = executionHistory.getData().getAttributeValue("in");
            if (in instanceof Data)
            {
                Data data = (Data)in;
                logger.info(data);
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I've created a simple demo project here: &lt;a href="https://answers.axonivy.com/upfiles/engineExecutionListener_641.iar"&gt;https://answers.axonivy.com/upfiles/engineExecutionListener_641.iar&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="alt text" src="https://answers.axonivy.com/upfiles/bpmEngineListenerLog.PNG"&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Tue, 06 Dec 2016 12:51:03 -0500</pubDate><guid>https://answers.axonivy.com/questions/2244/can-we-monitor-ivy-process-programmatically/2246</guid></item></channel></rss>