< Previous | Next >

Task 2-2: Creating a rule agent

The second agent in the tutorial is a rule agent.

About this task

The second agent in this tutorial uses several rules to respond to transactions:
  • Flags transactions that are risky
  • Prevents too many transactions per day
  • Warns of international transactions
  • Flags large transactions
  • Updates accounts based on the transactions

Because the writing of rules is not the focus of this tutorial, you enter one rule and then import the remaining rules.

Procedure

  1. In the Solution Map view, click Add rule agent.
  2. In the New Rule Agent Project window, specify a project name of CreditCardRules.
  3. In the Solution Project field, ensure that the MyCreditCardSolution project is selected, and click Finish.

    As before, you complete four parts of the descriptor: entity, event, source, and target. For this rule agent, the entity is the Account that you defined in the business model. The agent priority is High, so this agent is run before the Java™ agent. The event is the same Transaction business event that is used in the Java agent. The where condition is also identical.

    The final agent must be as follows:

    Descriptor for the rule agent

    Enter the descriptor by using the completion menus or by copying in the following code:
    'CreditCardRules' is an agent related to an account, whose priority is High,
    processing events :
    - transaction  , where this account  comes from the account of this transaction  
  4. Click Save.
  5. In the Solution Explorer view, select the rules folder for the CreditCardRules agent.
  6. Right-click New > Action Rule.
  7. In the Package field, type my_rules. A package with that name does not exist, but will be created.
  8. In the Name field, type Transaction Out Of Country, and then click Finish
  9. Type or copy and paste the following rule into the Content area of the rule editor:
    when a transaction occurs , called 'the transaction'
    if
        the country code of 'the transaction' is not "US"
        and the amount of 'the transaction' is more than 1000
    then
        emit a new authorization response where
            the account is 'the account' ,
            the message is "R01: Out of country transaction greater than 1000" ,
            the transaction is 'the transaction' ;
  10. Click Save.
< Previous | Next >