Updating the Event Preprocessor
- Procedure
- In TIBCO BusinessEvents Studio, open the rule function.
-
Click the Source tab at the bottom of the editor to work in the Source view.
In the Project Design Tutorial you worked in the Form view. You could stay in that view, but it’s good to become familiar with both views.
- In the
Scope section, replace
Event request
withEvents.AccountOperations request
. The section looks like the following:scope { Events.AccountOperations request; }
The reason you have to narrow the scope is that the base Event class does not have an
AccountId
property, so it cannot be used in the function you’ll add in the next step. - In the
Body section, add two new lines (shown in bold), just before the closing bracket:
body { // Replies to the request event, in order to close the HTTP request. // To keep it simple, uses the request event as the response. Event.replyEvent(request, request); // Attempts to load any existing matching account. Cluster.DataGrid.CacheLoadConceptByExtId(request.AccountId, false); }
The
Cluster.DataGrid.CacheLoadConceptByExtId()
function loads any matching items from the cache into the Rete network. In this case, it loads any concept whoseExtId
matches theAccountId
in the incoming event. The loading is done before the event is asserted, so the Rete network will contain any matching Account concepts. TheBadCreateAccount
rule then fires and as in the Project Design Tutorial, to prevent creation of duplicate accounts.