Updating the Event Preprocessor

    Procedure
  1. In TIBCO BusinessEvents Studio, open the RuleFunctions > PreProcessor rule function.
  2. 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.

  3. In the Scope section, replace Event requestwith Events.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.

  4. 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 whose ExtId matches the AccountId in the incoming event. The loading is done before the event is asserted, so the Rete network will contain any matching Account concepts. The BadCreateAccount rule then fires and as in the Project Design Tutorial, to prevent creation of duplicate accounts.

ResultYou have modified the basic FraudDetection project to load instances from the cache into the Rete network using an event preprocessor. This enables the project code to check for existing instances first, when creating new ones.
What to do nextNext you will work in the Cluster Deployment Descriptor to create two agents of different types.