Creating iWay Enable Rules

How to:

The Rule set name "SalesByRegion" was called earlier by the sales.process.tap1. This section shows you how to work with the Rule editor to create Rules and Rule sets and how to use Rules to create business events or take actions based on a given condition.

_erules("SalesByRegion",xpath("/TRANSACTION/Region"))

You can now configure the Rule set "SalesByRegion" using the iWay Enable Rules editor in the iWay Service Manager Administration Console. The Rules pane is used to define and organize iWay Enable rules. These Rules are used to determine if their corresponding actions should be performed. A Rule contains a Condition which always returns true or false and an Action which if the condition returns true is executed.


Top of page

x
Procedure: How to Create iWay Enable Rules

To configure iWay Enable Rules:

  1. Click Tools in the top pane of the iWay Service Manager Administration Console.

    The iWay Service Manager Tools pane opens.

  2. In the left pane, select Rules under the Real-time section.

    The Rules pane opens, as shown in the following image.

    You can now create the Rule set SalesByRegion which contains the following three Rules:

    • isRegionCA
    • isRegionFL
    • isRegionNY
  3. Click the Add button to add the Rule set name SalesByRegion.

  4. After the Rule set is created, right-click the rule set SalesByRegion by selecting New and then Rule.

  5. Name the rule isRegionCA and in the Condition section, select is from the Pick one drop-down menu, and type CA in the field next to it, as shown in the following image.

    The condition checks to see if the incoming XML message has the value CA for the field Region.

    Afterwards, you will need to configure what Action takes place when the condition is matched.

    An Action is simply some work you would like to perform, for example, sending an email, exposing an event, or even calling another Rule or Rule Set to execute.

    In this example, you can expose an Event when the condition matches.

    <TRANSACTION>
      <Region>CA</Region>
      <SalesChannel>Store</SalesChannel>
      <ProductName>Hammer</ProductName>
      <ProductCat>Hardware</ProductCat>
      <CostPrice>5</CostPrice>
      <SalePrice>10</SalePrice>
      <ItemSupplier>LMG</ItemSupplier>
      <Quantity>4</Quantity>
      <ShippingCost>0</ShippingCost>
    </TRANSACTION>
  6. Under Action, select Custom and type in the following expression:
    script.exposect('sales.region.ca',cid,script.xpath('//Region'));

    This expression uses an IFL function called _exposect() to expose events.

    _exposect("event name", cid, value) takes a required event name, a required CID (Correlation ID) or timestamp as a long or both delimited by a pipe, and an optional value. The IFL function will parse the value to determine the correct data type when creating the event table.

    In the above example, you created a business event called "sales.region.ca", and for each occurrence of "sales.region.ca" a value of the corresponding "SalePrice" will be assigned to the value field for that event in the event table.

  7. Click Save.

    The Save button changes to Saved as shown in the following image.

  8. Repeat steps 5 to 7 to create Rules for isRegionFL and isRegionNY and business events for sales.region.fl and sales.region.ny as shown in the following images.

  9. After creating the three rules, click the SalesByRegion rule set and you will see the list of the Rules you created in the previous steps.

    The list of rules you previously created appears.

  10. Check the On checkbox next to the name of each Rule to activate the rules.
  11. Click First True to run until the first rule returns true.

    Note: You can select All to run all the rules each time a message is passing through the tap, or you can select First True to run until the first rule returns true as shown in the following image.

    You are now able to tap into incoming data through the process flow (sales.process) that was configured earlier and generate business events based on the above Rules. The events will be associated with real-time feeds, ready to be incorporated into dashboards, composite applications, and other components.


iWay Software