Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

This content has been archived and is no longer being updated.

Links may not function; however, this content may be relevant to outdated versions of the product.

Using event strategy in Pega 7 Platform real-time event processing (7.1.9)

Updated on August 31, 2021

Event strategy is a visual representation of processing logic that is applied to all events coming from a data source. Event strategies can be used to specify patterns of events, query them across a data stream, and react to the emerging patterns.

The event strategy that you create in this tutorial identifies telecommunications company customers who have more than two dropped calls within a week. When such an event pattern occurs in the telecommunications network, a new case is called for each affected customer.

This walkthrough takes approximately 40 minutes to complete.

Requirements

Before starting this tutorial, build a simple Pega application on the PegaDM app (for details, see Creating an enterprise application). In your application, create the following resources:

  • A data flow called Call Detail Record to handle transactions that occur in the telecommunications network. Create the data flow in the <organization_name>-<app_name>-Stream class. For details, see Data Flow rule.

  • A stream data set called CDR Stream and a Database Table data set called Customers Info. The CDR Stream data set processes a continuous stream of call detail records. The Customers Info data set should contain properties such as customer name and contact information. You supply this data by using an additional data set because these properties are not typically in the stream of call detail records. Create the data sets in the <organization_name>-<app_name>-Data class. For details, see Data Set rule.
  • A case called Contact Customer. It starts for all customers who have two or more dropped calls within a week. For details, see Adding a top-level case type.

Creating a stream data set

The stream data set that you create processes a continuous stream of call detail records coming from a telecommunications network.

  1. In the Application Explorer, right-click the <organization_name>-<app_name>-Data class and click Create > Data Model > Data Set.
  2. Define the record configuration of the data set:

    1. In the Label field, enter CDR Stream.
    2. In the Type field, select Stream.
    3. Ensure that the Apply to field contains the class where you want to save the data stream (<organization_name>-<app_name>-Data).
    4. Click Create and open.
    5. In the Stream tab of the newly created data set, you can view the services that can be used to populate the data set outside of the Pega 7 Platform.
  3. Click Save.

After you create the required resources, you can create an event strategy.

Creating an event strategy

The event strategy that you create and reference from the Call Detail Record data flow is shown in the following figure:

Event strategy using the Call Detail Record data flow

In this figure, the event strategy filters dropped calls for each customer and creates a one-week time window to hold the dropped calls. Next, it counts the dropped calls from the one-week window for each customer. Finally, when the number of dropped calls for a particular customer is higher than two, the Call Detail Record data flow triggers the Contact Customers case.

  1. In the Application Explorer, right-click the <organization_name>-<app_name>-Stream class and click Create > Decision > Event Strategy.
  2. Define the record configuration of the event strategy:

    1. In the Label field, enter DroppedCallsDetection.
    2. Ensure that the Apply to field contains the class where you want to save the event strategy (<organization_name>-<app_name>-Stream).
    3. Click Create and open.

    A new instance of Event Strategy opens.

    Event strategy instance

  3. Double-click the Real-time data shape. The Real-Time Data Properties dialog box opens.

    1. In the Name field, enter Call Detail Record.
    2. In the Event timestamp section, select the System time check box.
    3. Click Sub​mit.
  4. Navigate to the Real-time data shape, click the Add icon on the right, and then select Filter.

    Location of the Add icon in the event strategy form

  5. Double-click the Filter shape. The Filter Properties dialog box opens.

    Specify a property from the CDR Stream, which is used to identify whether a call was dropped. In this tutorial, this is a TrueFalse property. When it is set to true for a particular call detail record, it means that the call was dropped.

    1. In the Name field, enter Dropped Calls.
    2. Click Add condition.
    3. In the field on the left, specify a CDR Stream property to be used by the filter.

    4. From the drop-down menu, select the equal sign (=).
    5. In the right field, enter true.
    6. Click Submit.
  6. Navigate to the Real-time data shape and click the bottom Add icon to add a Static Data shape.

  7. Double-click the Static Data shape. The Static Data Properties dialog box opens.

    Specify the properties that you want to associate with the properties in the CDR Stream. The properties that you specify come from the Customers Info data set that you created; this data includes customer name and contact information.

    1. Click Add field.
    2. Provide the name of a property.
    3. Repeat the step for the next property.
    4. When you finish, click Submit.
  8. Navigate to the Filter shape, click the Add icon, and select Window.
  9. Double-click the Window shape. The Window Properties dialog box opens.

    Configure a time window to hold the dropped calls coming from the CDR Stream. This sliding window contains the events for one week. When this window gradually moves with the passing of time, the events that are older than one week are removed from the window.

    1. In the Name field, enter One Week.
    2. In the Window section, select the Sliding check box.
    3. From the drop-down menu, select Weeks.
    4. In the Look for last field, enter 1.
    5. Click Submit.​
  10. Navigate to the Window shape, click the Add icon, and select Aggregate.
  11. Double-click the Aggregate shape. The Aggregate Properties dialog box opens.
    1. In the Name field, enter Count of Dropped Calls.
    2. Click Add aggregator.
    3. From the drop-down menu, select Count.
    4. In the Aggregate field, name the property that should contain the result of your aggregation function, for example, DroppedCallsNumber.
    5. Click Submit.
  12. Navigate to the Aggregate shape, click the Add icon, and select Filter.
  13. Double-click the Filter shape. The Filter Properties dialog box opens.
    1. In the Name field, enter Over 2 Dropped Calls.
    2. Click Add condition.
    3. In the left field, enter DroppedCallsNumber.
    4. From the drop-down menu, select the greater than sign (>).
    5. In the right field, enter 2.
    6. Click Submit.
  14. Double-click the Emit shape. The Emit Properties dialog box opens.
    1. In the Name field, enter Open Case.
    2. From the Emit event drop-down menu, select Only once.
    3. Click Submit.

You have just created and configured an event strategy instance called DroppedCallsDetection. Now, you need to reference it from the Call Detail Record data flow that you created at the beginning of this tutorial.

Referencing an event strategy from a data flow

Event strategies are used in data flows through the Event Strategy pattern. In this task, you reference the CDR Stream from the Source pattern in the Call Detail Record data flow and the DroppedCallsDetection event strategy from the Event Strategy pattern.

  1. Open the Call Detail Record data flow and double-click the Source pattern.
  2. From the Source drop-down menu, select Data set.
  3. In the Data set field, enter CustomersInfo.
  4. Click Submit.
  5. Navigate to the Source pattern.
  6. Click the Add icon and select Event Strategy.
  7. Double-click the Event Strategy pattern. The Event strategy properties dialog box opens.
  8. In the Results in field, specify the class that contains the event strategy (<organization_name>-<app_name>-Stream).
  9. In the Event strategy field, enter DroppedCallsDetection.
  10. Add mapping between the properties from the DroppedCallsDetection event strategy and the Call Detail Record data flow.

    First, you need to map the class key of the class containing the data flow with the class key of the Result in class of the event strategy. Next, you map the properties from the class that contains the data flow with the Result in class of the event strategy.

    1. Click Add Item.
    2. In the Target column, select the class key of the class that contains the Call Detail Record data flow.
    3. In the Source column, select the class key of the class that contains the DroppedCallsDetection event strategy.

    4. Map other properties in the same way.

    5. When you finish adding mapping, click Submit.

When you finish this task, the Call Detail Record data flow should look like this example:

Call Detail Record data flow after mapping is complete

Configuring a Database Table data set in a data flow

Because you are using the Customer Info Database Table data set to provide additional properties that are not typically in the stream of call detail records, you need to configure the data set in the Call Detail Record data flow.

  1. Double-click the Customers Info data set shape.

  2. In the Class field, specify the class that contains the Customers Info data set (<organization_name>-<app_name>-Data).
  3. In the Data set field, enter CustomersInfo.
  4. Add mapping between the properties from the DroppedCallsDetection event strategy and the Customers Info data set.

    First, map the class key of the class that contains the event strategy to the class key of the class containing the data set. Next, map the static properties from the event strategy to the properties from the class that contains the data set.

    1. In the Source column, select the class key of the class that contains the Customers Info data set (<organization_name>-<app_name>-Data).

    2. Click Add Item.
    3. In the Target column, select a property from the class that contains the DroppedCallsDetection event strategy.
    4. In the Source column, select a property from the class that contains the Customers Info data set.

    5. Map the other properties in the same way.

    6. When you finish adding mapping, click Submit.

  5. Click Save.

When you finish this task, the Call Detail Record data flow should look like this example:

Call Detail Record data flow after mapping

Referencing a case from a data flow

Finally, you need to reference the Contact Customer case from the Call Detail Record data flow. This case is triggered for each customer who has more than two dropped calls within a week.

  1. In the Call Detail Record data flow, click the Destination shape.
  2. From the Destination drop-down menu, select Case.
  3. From the Case drop-down menu, select CustomerCase.
  4. Click Submit.

When you finish this task, the complete Call Detail Record data flow should look like this example:

The Contact Customer case referenced from the Call Detail Record data flow

Creating a real-time run of a data flow

Now your tutorial is almost completed. You can create a real-time run of the Call Detail Record data flow that uses the newly created DroppedCallsDetection event strategy.

  1. Open the Call Detail Record data flow.
  2. Click Actions and select Run.
  3. In the Data Flow Test Run dialog box, click Activate.

After you create the real-time run of the data flow, you need to feed data to the CDR Stream data set.

  1. Open the CDR Stream data set.

    CDR Stream data set page

  2. Use one of the available services to populate the CDR Stream data set with call detail records.

    Some web browsers allow you to use free extensions to construct WebSocket requests or HTTP requests. You can use these extensions to deliver data to the CDR Stream.

  3. Click View example to check the payload format that you need to use in the WebSocket requests or HTTP requests.

As soon as you create the data flow run and feed data to the stream data set, the data set starts to deliver the call detail records to the data flow. The event strategy identifies customers who have more than two dropped calls within a week and the data flow triggers the case for each of the customers.

Click DesignerStudio > Decisioning > Decisions > Data Flows > Real-time Processing and open the Call Detail Record data flow. In the Data Flow Run window, you can view details of the run.

  • Previous topic Using event strategy in Pega 7 Platform real-time event processing (7.2.2)
  • Next topic Troubleshooting decision management components

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us