So go ahead and start Event Designer. I've created a new Event Project called DeveloperHat01, and then right clicked in and selected create new Event. I'm going to click next and name my event CustomerValueEvent and then click finish. I am not going to assign a connector to this event.
Next I'm going to create a Business Object that contains the same information as the Event Object. The Business Object will have verbalizations so that we can write rules against it. So right click in the project, select New... Business Object. Name it CustomerValueBO. Click Next. Select Create Business Object with the same fields as an event object. Click next, and then select the CustomerEventEO as shown below and click Finish.
Now let's create an Action so that when a rule triggers something will happen. Right click in the project and select New... Action.
Create a blank action. Click next. Name it CustomerValueAction. Click next. and select the File System connector so that it will write to the file system when our rule gets triggered. And then just as we did when creating the Event Object we'll create a new Action Object. Call it CustomerValueAO and give it two fields just like before called CustomerID and Value.
Here's where action objects are different than event objects. We have to tell Action Objects where to get their data from. So for each of the fields, go ahead and map them to the fields in the Business Object.
Now, because we've defined a file system connector for this Action, we'll need to tell it where to write to. We do that by selecting the Connector Tab, and setting the file path and filename pattern. In this case c:/temp and *.xml will work for us.
Next we're going to define a Event Rule. Right Click in the project and select New... Event Rule. Name it CustomerValueRule01, click Next. Have it trigger when the customerValueEvent is detected, click next. Have it use the System Context. The context is what holds the event correlation information. Click Next. And let's have it correlate against the CustomerID.
The content of the rule will say:
if the value of the customerValueBO is more than 10 then customerValueAction ;
So quite simply, if any events come in that have a customer value > 10 we will trigger our output Action. There is a lot more we could do with events that would make them more meaningful, but for now let's just test this one just to show how they work.
So now we want to deploy this project to the Events Server. Right Click on the project. Select Deploy... All Assets... and provide the server information. For a default ODM / Sample Server install this might be localhost, 9080, admin, admin and http protocol. Click Finish. You might have to enter another password at this point.
In a minute you'll see a dialog that says, Successful Deployment to Runtime.
Now we can open a Web Browser to our test widgets. http://localhost:9080/EventWidgets Log in as your test user, which might be admin / admin if you did the default install of SamplesServer. You should see a screen similar to this one. If you do not, then you might want to review Part 3 of this Lab. You've either logged in as a user that does not have test privileges or you do not have the one or more of the Test Widget Ear files installed or some combination of these:
Click on the Event Tester Widget. And from there click on Select Event Template. Select the CustomerValueEvent and click OK. Enter a customerID of 1 and a value of 1. Go ahead and click Send Event. Then look at the filters tab. You'll see that we received a CustomerValue Event. But if you check the actions tab, nothing will have fired. Go back to the first tab. Do this again with a customerID of 2 and a value of 20 and you should see different results in the actions tab.
And in fact if we open a file browser to the c:\temp folder we will find an xml file with a long name and the following content, which shows that we've written a WBE version 6.2 Connector Bundle, showing the customer value and customer ID.
<?xml version="1.1" encoding="UTF-8"?>
<connector xmlns="http://wbe.ibm.com/6.2/Action/CustomerValueAction" name="WBE" version="6.2">
<connector-bundle id="357B93DB17A280095B11E3C602377689" name="CustomerValueAction" stream="2" type="Action" workflow="FACE">
<CustomerValueAO>
<Value type="Integer">20</Value>
<CustomerID type="String">2</CustomerID>
</CustomerValueAO>
</connector-bundle>
<system>Base-Win2k8x64</system>
<timestamp>2013-08-20T01:46:27.368-04:00</timestamp>
<loginfo>This is an action from Decision Server</loginfo>
</connector>
In the next lab we will write an event packet directly to the JMS bus in the ODM Events Server and get a similar result.
No comments:
Post a Comment