Today I will illustrate how to setup Event Analytics for Infor Process Automation (IPA). Event Analytics is an application that subscribes to Event Hub, that filters events based on conditions, and that takes actions. My goal is to single out specific Infor M3 events to trigger IPA flows with accuracy, for example to trigger a HelloWrrrld flow only when an M3 Item number ABC123 has changed from Status 10 to 20, specifically. This post is intended for readers already familiar with IPA and Event Hub, yet not too familiar with Event Analytics. For an introduction on Event Hub for IPA, I invite you to read my previous article.
About Event Analytics
Event Analytics is an application for the Infor Grid that subscribes to Event Hub. It uses a rules engine with business rules to single out specific events out of the million of events produced by M3, i.e. it will find the needle in the haystack, and it will carry out actions. It’ s fast and scalable and doesn’t affect M3 performance. It’s used for example to pass Business Object Documents (BODs) to Infor ION.
It uses the Production Rule System JBoss Drools, a “Business Logic integration Platform which provides a unified and integrated platform for Rules, Workflow and Event Processing”, and it uses the Drools Rule language, a declarative domain-specific language that looks like when <condition> then <action> . Drools Rule files have the .drl extension. The Smart Rules Editor is an optional plugin for Eclipse based on Drools Expert to help produce Drools Rules for Event Analytics. For further reading on JBoss Drools and Drools Rules, I recommend the Rules Programming tutorial by Srinath Perera.
The Infor LifeCycle Manager (LCM) InfoCenter has detailed documentation about Event Analytics: facts, subscriptions, administration, example rules, etc. For that, go to your LCM InfoCenter at http://lcmserver:4062/ and then navigate to Documentation > Infor Smart Office Infocenter > Installation Guides > Infor ION Grid Extensions Installation and Administration Guide > Event Hub and Event Analytics Grid Extensions:
Event Analytics or Event Hub?
Why should we use Event Analytics to trigger IPA flows when we can use Event Hub alone? Well, if we used Event Hub alone to directly trigger IPA flows we could potentially get too many false positives. For instance, in my example above I want to trigger a flow only when the Item number ABC123 has changed from Status 10 to 20; I don’t want events for other Item numbers nor Statuses. Unwanted events would create too many unnecessary WorkUnits in IPA, and that would clog the server with noise in the database even if we used an if-then-else Branch activity node at the start of the flow to eventually cancel the execution downstream. The solution is to filter events upstream with Event Analytics.
Once a condition is met in a Drools Rule, a typical action for Event Analytics is to post a new event to Event Hub. Then, subscribers like IPA can subscribe to those events with Publisher:EventAnalytics instead of the traditional Publisher:M3. Thus, Event Analytics is dual subscriber and publisher. It took me a while to figure out the gymnastics in my head, eventually it became clear.
Here is an illustration:
The HelloWrrrld scenario
For illustration purposes in this article, the simple scenario will be to trigger a HelloWrrrld flow when an M3 Item number ABC123 has changed from Status 10 to 20. The baby steps will be:
First, I will create a Drools Rule that will subscribe to events where Publisher:M3, Document:MITMAS, and Operation:U, and with the conditions ITNO=ABC123, old STAT=10, and new STAT=20. If that condition is met, the Rule will carry out the action to post a new event MITMAS_ABC123_20.
Then, with Infor Process Designer (IPD), I will create and deploy a simple HelloWrrrld flow. The flow will receive as input variables all the data from the event. So I will add a simple activity node that will show the M3 fields <!CONO>, <!ITNO>, <!ITDS>, and <!STAT>.
Then, in IPA Rich Client Admin, I will create a new Event Hub Receiver with a subscription to EventAnalytics:MITMAS_ABC123_20 that will trigger the HelloWrrrld flow.
Then, I will do a test. I will go to MMS001 in Smart Office, I will prepare an Item ABC123 with Status 10, I will save it, and then I will change it to Status 20. I will also update other Items to produce additional events (noise). M3 will send all those events to Event Hub. Event Hub will pass those events to Event Analytics. Event Analytics will single out the event that matches the condition ITNO=ABC123, old STAT=10, new STAT=20, and it will post a new Event MITMAS_ABC123_20. Then, the Event Hub Receiver will receive that event and will trigger my HelloWrrrld flow with the data.
Finally, the resulting WorkUnit will contain all the variables of the event, the M3 fields, the old values, and the new values.
OK let’s do it.
Create a Drools Rule
First, let’s create the new Drools Rule in Event Analytics:
- Go to Infor LifeCycle Manager (LCM).
- Find EventAnalytics in your Grid (expand the tree or use the filter).
- Right-click > Manage Application.
- There will be one or more Sessions. We’ll use Session Default for now. Click Rules.
- There will be zero or more Drools Rule Language Files, active or not. Click Create.
- Enter a Resource Name, for example MITMAS_ABC123_20_Rule.
- The editor will generate a sample Drools Rule with subscription M3:MITMAS:U, and condition elementValues[“STAT”]=”20″. Good. We’ll keep that.
- Rename the rule MITMAS_20_Demo to MITMAS_ABC123_20_Demo.
- Add the condition elementValues[“ITNO”]=”ABC123″ .
- Add the condition elementOldValues[“STAT”]=”10″ .
- In the actions, rename the postEvent to MITMAS_ABC123_20.
- Delete the rules Start_Demo, Time_Demo, and Stop_Demo.
- Click Save.
- The result will look like this:
- Close the editor.
- Back in the list of Drools Rule Language File, select the checkbox next to your Rule to activate it.
- Click Reload to load your Rule.
- Verify in the list of Rules that your Rule is now there.
Create a HelloWrrrld flow
Then, with Infor Process Designer (IPD), let’s create and deploy the simple HelloWrrrld flow that will show the M3 fields <!CONO>, <!ITNO>, <!ITDS>, and <!STAT>.
Create an Event Hub Receiver
Then, let’s create the new Event Hub Receiver in IPA Rich Client Admin:
- Go to IPA Rich Client Admin.
- Switch to the desired data area (development, test, production, etc.)
- Open Channels Administrator.
- Create a new Event Hub Receiver.
- Set the Subscription to EventAnalytics:MITMAS_ABC123_20.
- Select Process HelloWrrrld.
- Select Startup Type Automatic.
- Click Save.
- Select Actions > Activate.
- The status bar will show “Activate Completed”.
Test in Smart Office
Then, let’s do a test in Smart Office.
- Go to MMS001 in Smart Office.
- Create an Item ABC123 with Status 10, and save it.
- Change the Item to Status 20:
- Optionally, update other Items to produce additional events (noise).
If you liked this post, please subscribe to this blog by clicking the Follow button below. And leave your comments in the section below. That will support and grow the community. Also, spread the word to your colleagues, customers, and partners. And if you have something to share, let me know and I will send you an author invite. And even better, create your own blog to grow the community even more.