Setting Up Events

This chapter provides an overview of event setup and event handlers and discusses how to:

Click to jump to parent topicUnderstanding Event Setup

To implement Event Manager into your application processing:

  1. Identify the business events that drive the execution of your business logic and, if necessary, define a new event.

    In many cases, the event is already defined in the local event registry that is accessible through the Event Registry component. If the event is not yet defined, you must define a new business event. To define a new event:

    1. Create an Application Package in PeopleTools Application Designer.

      This Application Package is a container for your Handler application classes. It needs to contain a sub-package named Handlers with individual application classes under it for each Handler you wish to register.

    2. Register the event to the Event Manager framework through the Event Registry component.

  2. Write the event handlers in PeopleTools Application Designer to execute the business logic that is specific to the event.

    To develop an event handler, create an Application Class with a method named ProcessEvent() that includes the Event Manager interface code that is provided in this chapter. Event handlers can be for one or more business events.

  3. Register the event handlers to the event through the Event Registry component.

  4. Test your event and its registered event handlers.

    To test event handlers and events:

    1. Test the event handler in standalone mode through the Handler Tester component.

      Note. This test method does not require Integration Broker to be running.

    2. Test the event independent of the business process that raises the event through the Event Tester component.

      Note. This test method requires Integration Broker to be up and running.

    3. Test the event in the context of the business process by executing the business process that raises the event through the component or PeopleTools Application Engine process.

      The Event Manager framework automatically executes the registered event handlers for an event when you raise the business events.

Click to jump to parent topicUnderstanding Event Handlers

Business events are the functions in a business environment, such as adding a person, changing an employee’s compensation rate, terminating an assignment, promoting an employee, and so on. After the events are created, you register events in the Event Registry component. Event handlers are modules of business logic that react to instances of particular events to which they are registered. You must register event handlers to events so that the Event Manager framework executes the event handlers whenever the event is raised.

You can assign multiple event handlers to a single business event, and you can assign a single event handler to react to multiple events. When defining events in the Event Registry component, you can assign event handlers to function in either synchronous mode or asynchronous mode with respect to the process that raises the associated event. When a process raises a registered event, the Event Manager framework determines whether the event handlers that are registered to that event are synchronous or asynchronous. If an event handler is synchronous, the Event Manager framework executes that event handler inline as part of the process that raises the event. If the event handler is asynchronous, the Event Manager framework executes the event handler as a detached process that is out of the critical path of the mainline process. You can register both synchronous and asynchronous event handlers concurrently to the same event. The Event Manager framework executes the registered event handlers in whichever mode you configure them to operate, always executing synchronous event handlers first. When defining event handlers for registry in multiple events, you should include some code in the event handler to examine the Name property of the passed-in event object so that you know which type of event caused the event handler to be executed.

The Event Manager framework is based upon a simple notify and respond model. For the notification side, the Event Manager framework broadcasts that event has occurred, along with the data that caused the creation of the event instance. For the respond side, the individual applications link business logic into the Event Manager framework to respond to the business event. By linking PeopleTools Application Classes to the event in the Event Registry component, the Event Manager framework knows when to execute the registered event handlers for the event when the event is raised.

An event handler that fails during execution causes a disruption to the execution of any other event handlers for that event or the mainline process. The Event Manager framework therefore provides many options for monitoring and troubleshooting event handlers and events. You can monitor event instances and the executions and exceptions of the event handlers through the Event Monitor component or the Event Summary component. You can also test event handlers and events outside of the mainline business process through the Handler Tester component and the Event Tester component.

Local and Remote Nodes

The Event Manger framework enables you to manage events that have influence over more than one database instance. You can use the Event Manager framework to process business events that occur on either a local or remote database (also called a node). A remote node can execute only event handlers that are implemented locally and registered to events in its local event registry. For example, an event that is raised in an HCM database might be important to a separate PeopleSoft Enterprise Learning Management (ELM) database or a PeopleSoft Financials database.

The Event Manager Framework is currently not integrated with the Service Oriented Architecture (SOA) distributed registry. Instead, each database has its own local event registry. Within a local event registry, you can define events that you can raise by local process as well as events of interest to applications on the local database that are raised by remote databases. To support the processing of an event in a remote database, remote databases must implement the Event Manager framework. Also, each local event registry must contain entries for the remote events of interest along with their associated local event handlers.

From the perspective of the Event Manager framework, virtually no difference exists between the way that asynchronous handlers are supported for remote events and local events. You register event handlers to events in the event registry, configuring the Event Manager framework to execute event handlers for events that are raised in the local database, a remote database, or both types of databases. Thus, a single event handler can respond to instances of the same event that are raised on the local database as well as a remote database.

Event handlers for remote events are by definition asynchronous. Thus, on the local database the Event Manager framework executes these remote events only after completing the execution of synchronous handlers that you have registered for the event.

Example: Local Event with Synchronous Event Handlers

This example illustrates the processing of a mainline business process on a local database using an event with two registered synchronous event handlers. In this scenario, the mainline business process calls the application program interface (API) for the Event Manager framework to raise the event. The framework executes inline the two event handlers in order, publishes the generic PeopleTools Integration Broker event message, and then returns processing control back to the mainline business process.

Local event with synchronous handlers

Example: Local Event with Asynchronous Event Handlers

This example illustrates the processing of a mainline business process on a local database using an event with two registered asynchronous event handlers. In this scenario, the mainline process calls the API for the Event Manager framework to raise the event. The framework immediately publishes the generic PeopleTools Integration Broker event message, and returns processing control back to the mainline process without delay. A normal PeopleTools Integration Broker local subscription picks up the generic event message and invokes the framework to execute the asynchronous event handlers that are registered to the event.

Local event with asynchronous handlers

Example: Local Event with Both Synchronous and Asynchronous Event Handlers

This example illustrates the processing of a mainline business process on a local database using an event with two registered synchronous handlers and two registered asynchronous event handlers. In this scenario, the mainline process waits while the Event Manager framework executes the synchronous event handlers. The Event Manager framework executes the asynchronous event handler as detached processes launched by the local subscription to the generic PeopleTools Integration Broker event message.

Example: Remote Event

This example illustrates event processing that spans across local and remote databases.

In Registry A, the event has both registered synchronous and asynchronous event handlers. The event handler that is registered to this event is set for a local source. When the event in raised in Registry A, the Event Manager framework logs the event (if it is configured for logging), publishes the generic event message, executes synchronous event handlers that are registered to the event, and then subscribes locally to the generic event message to execute asynchronous event handlers that are registered locally to the event.

Registry B has the same event active in its local event registry. The event handler that is registered to this event is set for a remote source. Because Registry B subscribes remotely to the same event message that Registry A publishes, Registry B logs the occurrence of the event and then executes the registered asynchronous handler.

Remote Event

Click to jump to parent topicDefining and Registering Events

To register business events and their event handlers, use the Event Registry (EOEN_EVENT_REG) component.

This section provides an overview of new events and discusses how to define and register events.

Click to jump to top of pageClick to jump to parent topicUnderstanding New Events

Occasionally, you need to create new events that you can raise in the system for use by the Event Manager framework. As stated in the chapter overview, the first step is to identify the business events that drive the execution of your business logic and, if necessary, define a new event. Recall that to define a new event you must:

If you want to register a new event handler to an existing business event, you can bypass this step.

Click to jump to top of pageClick to jump to parent topicPages Used to Define and Register Events

Page Name

Definition Name

Navigation

Usage

Define Events

EOEN_EVENT_REG

Enterprise Components, Events & Notifications, Event Framework, Event Registry

Register the business events that you want to be able to raise within the Event Manager framework.

Registered Handlers

EOEN_EVENT_REG2

Enterprise Components, Events & Notifications, Event Framework, Event Registry

Select the Registered Handlers tab

Register event handlers to the selected business event. The Event Manager framework executes event handlers according to the rules that you specify on this page whenever it receives notification that the specified type of event has been raised.

Click to jump to top of pageClick to jump to parent topicRegistering Events to the Event Manager Framework

Access the Define Events page (Enterprise Components, Events & Notifications, Event Framework, Event Registry).

Event Name

The system displays the name of the business event that you want to be able to raise within the Event Manager framework. If you are adding a new business event, enter the name of the event when accessing the component through the Add mode.

Event Status

Select whether the status of the event is Active or Inactive.The system only raises events in the local database that are active. Note that the system ignores inactive events that are raised in remote databases.

Description and (Long)Description

Enter a short and long description of the business event. The system uses the short description in search pages. You should provide enough detail of the business event in the long description so that anyone accessing the event knows what it represents.

Logging Enabled

Select to have the system write a row to a log table for each instance of this event. The system writes to the log each time that this event is raised in the local database. For events that are raised in remote databases, the system writes to the local log each time it receives a generic event message for this event.

Click to jump to top of pageClick to jump to parent topicRegistering Event Handlers

Access the Registered Handlers page (Enterprise Components, Events & Notifications, Event Framework, Event Registry).

The number of different events to which you can register a particular event handler is not restricted.

Handler Implementation

Sequence number

Enter a number to indicate the sequence in which the system executes the registered handlers when this event is raised. The execution sequence is important when more than one event handler is registered to an event.

Note. The sequence of event handler execution is relative to other event handlers that are operating in the same mode, either synchronous or asynchronous.

Sys Data (system data)

If this check box is selected, then PeopleSoft Human Resources delivers the event handler registration for this event as system data. You should not modify this system data unless PeopleSoft Human Resources instructs otherwise.

Package

Select the root application package that contains the application class for the event handler. The application class can reside within any application package; however, the application class must reside under a sub-package named Handlers.

Application Class Path

Select the application class that implements the event handler. The system displays as possible values all application classes that reside within the selected package as part of the Handlers subpackage.

Description

For information purposes, enter a short description of what the event handler does.

Status

Select whether the status of the event handler is Active or Inactive. The system executes event handlers that are in Active status only when this event is raised.

Handler Options

Event Source

Select the source from which you want the system to execute the event handler for this event. The Event Manager framework supports both local and remote events.

Possible values are:

  • Local & Remote: Select to have the system execute the event handler for instances of this event that are raised in either the local database or remote databases.

  • Local Only: Select to have the system execute the event handler for instances of this event that are raised in the local database only.

  • Remote Only: Select to have the system execute the event handler for instances of this event that are raised in remote databases only.

Handler Mode

Select the mode by which you want the system to execute the event handler for this event. This setting applies only to events that are raised in the local database.

Possible values are:

  • Asynchronous: Select to have the system execute the event handler as a detached or background process. The process that raises the event does not wait for all registered asynchronous event handlers to execute.

  • Synchronous: Select to have the system execute the event handler inline with the business process that raises the event. The process that raises the event does wait for all registered synchronous event handlers to execute.

Note. The Event Manager framework always executes synchronous handlers before asynchronous handlers, regardless of the values that you specify in the Order column.

Logging/Trace

Logging

Select how you want the system to log execution of event handlers. This option applies only if you select the Logging Enabled check box for the selected event on the Define Events page.

Possible values are:

  • All: Select to log every execution of this event handler. This option is available only if you select the Event Logging check box for the event of the Define Events page.

  • Errors: Select if you want to log execution of this event handler only when the execution fails. If you select this option for the event handler but do not enable logging for the event, then if the event handler fails, the system creates an event log entry along with the event handler log entry.

  • None: Select if you do not want to log execution of this event handler.

Trace

Select to include trace/debug entries in the execution log for this event handler. Use this option for debugging the event handler. This option is available only if you select to log all exceptions of the event handler by selecting the All value in the Logging field.

Click to jump to parent topicCreating Event Handlers

An event handler is the application-specific code that responds to a particular type of event. You must register event handlers to events so that when an event is raised, the Event Manager framework executes the appropriate event handlers.

Requirements for Creating Event Handlers

To be compatible with the Event Manager framework, when creating event handlers, you must implement all business logic for the event handlers to abide by the following set of standards and code requirements:

Details of the baseEvent Class

When the Event Manager framework invokes the baseEvent class, it passes the baseEvent class into the ProcessEvent() method of the application class of the event handler. This enables you to use the properties and methods of the base class to obtain more information about the event instance to direct internal processing of the event.

This table lists public properties of the event object that are of interest to application developers who are implementing the Event Manager framework:

Public Properties

Description

EventName

A string that is populated with the name (type) of the event instance. Examples are "AssignmentTerminated", "PersonAdded", and so on. If you are registering the same event handler to multiple events but these events have slightly different logic depending upon the exact event that is being processed, you can use this property to control your processing.

EventID

A numeric that is populated with the unique serial number that identifies this event instance for an originating node. Generally, event handlers do not have any need for this property. The event handler uses this property primarily inside the framework for audit and monitoring purposes.

ContextRecord

The context record associated with the event.

HasContextRecord

A Boolean set to True if the raised event has a context record.

IsLocal

A Boolean set to True if the event was raised by an activity in the local database. (The term local is relative to the domain in which the event handler code is executing).

EventNode

A string that is populated with the node name of the database in which the activity that raised the event occurred.

HandlerTraceEnabled

A Boolean that indicates whether the user wants the current event handler to create trace and debug information in the event handler log.

EventLoggingEnabled

A Boolean that indicates whether the user wants the current event to create event logging information in the event log.

Must be set to true if Event Handler logging is desired.

HandlerLoggingSwitch

A Boolean that indicates whether the user wants the current event handler to create event handler log information in the event log.

Event Handler Skeleton Code

You can use the following skeleton code as a starting point when building an event handler class:

import EOEN_EVENT_MANAGER:Base:baseEvent; import EOEN_EVENT_MANAGER:Base:Types:ExceptionType; class MyHandlerClass /** Dummy Constructor. */ method MyHandlerClass(); /** Process Event. */ method ProcessEvent(&inEvent As EOEN_EVENT_MANAGER:Base:baseEvent); end-class; method MyHandlerClass end-method; method ProcessEvent /+ &inEvent as EOEN_EVENT_MANAGER:Base:baseEvent +/ Local Record &recContext; /* the following lines are required only if you want to pass detail information about Errors, Warnings or other messages back to the Event Framework */ Local EOEN_EVENT_MANAGER:Base:Types:ExceptionType &myExceptionType = ⇒ create EOEN_EVENT_MANAGER:Base:Types:ExceptionType(); If Not &inEvent.HasContextRecord Then &myExceptionType.MESSAGE_SET_NBR = 18137; &myExceptionType.MESSAGE_NBR = 6509; &myExceptionType.MSG_SEVERITY = "E"; &myExceptionType.MESSAGE_TEXT = MsgGetText(18137, 6509, ⇒ "no message found", &inEvent.EventID, &inEvent.EventNode); &myExceptionType.EXPLAIN_TEXT = ""; &inEvent.HandlerStatus.AddException(&myExceptionType); Else ⇒ /*================================================================= */⇒ ⇒ /* ---------------- Business Logic goes here ------------------*/⇒ /*================================================================= */⇒ End-If; end-method;

Addressing Errors and Warnings

During execution, an event handler might encounter errors, warnings, or other issues that a user needs to be made aware of. In most cases, you want to pass this information back to the Event Manager framework so that users can view the information through the Monitor Events component. Although you do not have to pass this information back to the Event Manager framework, the more information that you do pass back, the easier it is for the administrator to resolve the problem.

The Event Manager framework uses a simple exception-array scheme to receive status information that is passed back to it from an event handler and subsequently displays that information in the Monitor Events component. The structure of the exception array is the same as the structure of a message in the message catalog. It contains a message set number, message number, severity level, message text, and explanation text in each row of the array. The message set number and message number are significant only if the information that you want to pass back to the Event Manager framework is described in a Message Catalog entry. If not, you can leave these two properties blank and just populate the message text, explanation text, and severity properties.

As mentioned previously, the event object that is passed into your event handler contains a complex property that is used to communicate the status of your event handler. At a minimum, you should populate the overall-status simple property with either (S)uccess or (F)ail prior to quitting your ProcessEvent() method. If you do not populate the overall status property, the Event Manager framework assumes that the event handler executed successfully. PeopleSoft recommends that you pass back information through the exception array of the complex property, although this is optional. For example, if the event object is passed into your handler as &inEvent, you populate the overall status property as:

&inEvent.HandlerStatus.ExecutionStatus = "S";⇒ /* Handler terminated successfully */

You never have to deal directly with the exception array that is embedded in the event object that the event handler receives. Instead, whenever you want to add an item to this array, you call the AddException() method, thus passing in an object that the system has already populated with exception information. This object that you pass in is an instance of the ExceptionType TypeClass. This class has the following properties:

The following example shows how to add a message to the exception array for a message that does not come from the Message catalog, assuming that the event object is passed into your event handler as &inEvent:

&myExceptionType = create EOEN_EVENT_MANAGER:Base:Types:ExceptionType(); &myExceptionEntry.MESSAGE_SET_NBR = 0; &myExceptionEntry.MESSAGE_NBR = 0; &myExceptionEntry.MSG_SEVERITY = "M"; &myExceptionEntry.MESSAGE_TEXT = "Hello World!"; &myExceptionEntry.EXPLAIN_TEXT = ""; &inEvent.HandlerStatus.AddException(&myExceptionType);

For a Message Catalog entry, you must include the message set number and the message number. You must also retrieve the text and explain text from the Message Catalog because substitution tokens might be involved that the Event Monitor framework cannot pass or resolve.

Note. If you use the AddException() method to create an exception array entry with the MSG_SEVERITY property set to (E)rror, then the system automatically sets the overall execution status indicator for the event handler to (F)ail. This means that you do not need to separately set the overall status property.

Note. The Event Manager framework executes all event handlers that you register to an event. If a particular event handler fails, the Event Manager framework still executes the remaining event handlers that are registered to the event. The Event Manager framework can catch exceptions that an event handler raises rather than terminating before it has finished executing all of the registered event handlers. However, the Event Manger framework does not contain any exception processing or error handling subsystems, and because of this you must ensure that event handler code does not raise an exception that the Event Manager framework cannot catch. One such exception is the PeopleCode error statement. Therefore, you must never raise an exception for an error statement in your event handler. Otherwise, the Event Manager framework stops and does not execute any remaining event handlers that are registered to the event.

Component Interface and SOA Service Exceptions

If you have PeopleSoft Human Resources two additional exception methods are available: Component Interfaces (CIs) and Service Oriented Architecture (SOA) services. The Event Manager framework therefore provides assistance to facilitate passing exceptions from these sources back to the Event Manager framework and ultimately into the Event Monitor component.

The system displays exceptions that are raised by CIs or SOA services on the Handler Exceptions page of the Event Monitor component, much like any other exceptions that are written to the log. For severity information, the system prefaces the message with “[CI] ” or “[SOA]”, respectively.

The structure of the event-handler exception log is similar to the exception structure within PeopleTools for CIs and within the SOA framework for SOA services. Essentially, you must pass these exceptions back to the Event Manager framework when they arise. Two methods are available within the Event Manager framework that enable you to do this easily. One method is:

.HandlerStatus.AddCIException(&arrExceptions as array of Record, &Severity as⇒ string)

This method copies all exceptions from a standard CI exception array to the exception log of the event handler according to the specified severity of the exception. Severity codes are (E)rror, (W)arning, and (M)essage.

You can specify multiple severity codes by concatenation. Thus, if you want to copy both errors and warnings, then specify a severity code of EW. A blank severity code causes the copying of all exceptions regardless of severity.

The structure of the exception array that is passed into this method is identical to the exception array that the FUNCLIB_CI version of the standard HCM CI wrapper uses. This is an array of Record.CI_EXCEPTIONS. If you're using the FUNCLIB_CI wrapper, you can pass the exception array that you use with those functions into this method.

If you are calling a CI directly, then you need to first ensure that you have instructed PeopleTools to redirect CI exceptions from the screen to the %Session.PSMessages object. Then, you need to copy the items from PSMessages into an array of Record.CI_EXCEPTIONS so that these exceptions can be passed into this method.

Another method is:

.HandlerStatus.AddSOAException(&inException As HMCR_TYPES:ExceptionTypes:Exception⇒ Type_v1_0:ExceptionType)

This method copies all exceptions from a standard SOA exception type structure to the exception log of the event handler.

When invoking SOA services, the system always executes them in a try/catch block. Typically, the event handler executes the services and catches certain defined exceptions that arise. A catch-all exception always catches any exceptions that have not been specifically called out.

SOA exceptions differ slightly from CI exceptions in that when invoking an SOA service, you manage only one (if any) exception. The exception that you pass into this method is the exception structure that you catch in your try/catch block.

The following example shows an SOA service invocation passing exceptions back to the Event Manager:

* try * &MyService.MyServiceManager.LocateService(&ServiceName); * &MyService.DoService(); * catch <NamedException1> &e1 * &myEvent.HandlerStatus.AddSOAException(&e1.ServiceException); * --- other exception processing --- * catch <NamedException2> &e2 * &myEvent. HandlerStatus.AddSOAException(&e2.Service⇒ Exception); * --- other exception processing --- * . . . * catch HMCR_FRAMEWORK:ServiceFramework:baseClasses:baseException⇒ &e0 * &myEvent. HandlerStatus.AddSOAException(&e0.Service⇒ Exception); * --- other exception processing --- * end-try

In this code, the items appearing as <NamedExceptionX> represent the application-specific exceptions that are registered in the SOA registry. These are exceptions that are known to be thrown by the indicated SOA service. The class named HMCR_FRAMEWORK:ServiceFramework:baseClasses:baseException is for the catch-all exception, defining the shape of the generic SOA exception.

Providing Trace/Debug Information

The Registered Handlers page of the Event Registry component provides a Trace check box to indicate whether to write trace/debug information to the execution log of the event handler. This functionality is available only when you set the Logging field for the event handler to the All value.

When you select the Trace check box, the event handler produces trace/debug in the handler execution log. The amount of trace/debug information that the system writes to the log is determined by the developer of the event handler. Generally, you must provide enough information so that anyone examining the event handler log can trace the path of the execution that the event handler has taken.

The system makes the selected value of this check box available to the event handler using the HandlerTraceEnabled Boolean property of the event. When this property is True, the event handler creates trace/debug entries in the exceptions structure. PeopleSoft software provides the following method to make the creation of these entries easier:

&myEvent.HandlerStatus.AddTraceEntry(&Heading, &Detail);

In the preceding code, &Heading is the string that appears as the first line of the entry, and &Detail is a long string containing whatever detailed trace/debug information you want to create.

The system displays the trace/debug information in the Event Monitor component.

No fixed rules are associated with the trace/debug entries that the event handler generates. This is a judgement call. You should provide whatever entries you think are useful to debug or troubleshoot the event handler code.

Create trace/debug entries only when the .HandlerTraceEnabled property is True. Thus, the code looks similar to:

If &myEvent.HandlerTraceEnabled Then &myEvent.HandlerStatus.AddTraceEntry("Method ABC()", "No data returned for:⇒ " | &Emplid); End-If;

Click to jump to parent topicTesting Event Handlers and Events

This section provides an overview of event testing and discusses how to:

Click to jump to top of pageClick to jump to parent topicUnderstanding Event Testing

Generally in a production environment, you raise events by making a change to application data through a component or by running a PeopleTools Application Engine process. When the event is raised, the Event Manager framework executes the event handlers registered with the event as defined in the Event Registry component. When testing events, you should begin at the lowest level, which is the event handler, and then work your way up to the highest level, which is the business process that raises the event. Thus, to test events:

  1. Test the event handler in standalone mode through the Handler Tester component.

  2. Test the event independent of the business process that raises the event through the Event Tester component.

  3. Test the event in the context of the business process by executing the business process that raises the event through the component or PeopleTools Application Engine process.

Click to jump to top of pageClick to jump to parent topicPages Used to Test Event Handlers and Events

Page Name

Definition Name

Navigation

Usage

Event Manager - Test an Event Handler

EOEN_HNDLR_TEST

Enterprise Components, Events & Notifications, Event Framework, Handler Tester

Execute a single event handler as a standalone process without raising an event. Use this feature for testing and debugging event handlers.

Event Manager - Raise an Ad-Hoc Test Event

EOEN_EVENT_TEST

Enterprise Components, Events & Notifications, Event Framework, Event Tester

Raise a selected business event that you have defined on an ad hoc basis without invoking the business process that normally raises the event. This enables you to test events without having to perform the business operation that normally raises the event.

Execute a single event handler as a standalone process without raising an event. Use this feature for testing and debugging event handlers.

Click to jump to top of pageClick to jump to parent topicTesting an Event Handler

Access the Event Manager - Test an Event Handler page (Enterprise Components, Events & Notifications, Event Framework, Handler Tester).

Event

Select the event to which the event handler that you want to execute is registered. Event handlers must always execute within the context of an event.

Record

When you select an event, the system also allows you to select a record to provide data for the event. Typically, this is the record in the database from which a data change normally raises the event. however you can select a different record. The record must have the same keys as the record that normally raises the event. After you select a record the fields from the record are populated on the page with fields to enter values, expected types and lengths. Enter your sample data for your Event Test in the value fields and click the Execute button.

The system displays in the Registered Handlers group box the event handlers that are registered with the selected event in the local database through the Event Registry component.

Registered Handlers

This group box displays the event handlers that you have registered with the selected event in the Event Registry component.

Execute

Click to execute the selected event handler. Before you can execute an event handler, you must select the event, record, and event handler and enter the event data that you want to pass to the event handler. You can execute only one event handler at a time.

The system executes the event handler immediately regardless of any settings in the Event Registry component. When testing an event handler through this page, the system does not raise an event, publish the generic PeopleTools Integration Broker message, or generate log entries.

The system displays the status of the event handler execution to the left of this button and displays any exceptions that the event handler creates in the Handler Exceptions group box directly on this page.

Indicates that you have not yet executed the event handler.

Indicates successful execution of the event handler.

Indicates that the system executed the event handler with a fatal error.

Handler Exceptions

Use this group box to view results of the event handler execution. The system displays event keys, exceptions, and trace information that is associated with the execution of the event handler.

The system displays the event data that the system used during the execution of the event handler. At a minimum, the system displays the event data in the Handler Exceptions group box after execution of the event handler.

The system displays the exception information that the system generated during execution of the event handler.

The warnings that the system generated during execution of the event handler.

The errors that the system generated during execution of the event handler.

The trace information that the system generated during execution of the event handler.

Event Fields

Use this group box to enter values for each of the fields that are part of the selected event and record. These are the values that the system passes into the event handler during the test. The system does not perform any validation on the data that you enter in the Value fields. Be sure to enter the correct format for data values and use uppercase or lowercase values for character data as appropriate. The system makes this data available to the event handlers as the Context Record for the Event.

Click to jump to top of pageClick to jump to parent topicTesting an Event

Access the Event Manager - Raise an Ad-Hoc Test Event page (Enterprise Components, Events & Notifications, Event Framework, Event Tester).

Event

Select the event that you want to raise. You can only raise events that are active in the local event registry. If you are unsure of the status of an event, select the event in the Event field and click the Event Info button.

Record

When you select an event, the system allows you to select a record to provide data for this event. Typically, this is the record in the database from which a data change normally raises the event.

The system displays the Event Fields grid so that you can enter data to pass to the event.

Click the Event Info button to view select information from the Event Registry component about the selected event and its registered event handlers. The system displays the Registry Info group box, which contains the event details.

Raise Event

Click this button to have the Event Manager framework raise the event with the specified event data.

The system processes the event and executes all active event handlers that you have registered to the event exactly as if you have raised it from the normal business process such as through a component or PeopleTools Application Engine process.

The system displays a message below the Record field indicating whether you have successfully raised the event. This message also includes the event ID on the local node and, for multichannel events, the event channel.

Launch Event Monitor

After you raise the event, click this link to view the execution status of the raised event. The system launches the Event Monitor component in a new browser window and automatically displays information for this particular event instance.

Registry Info

Use this group box to view select information from the Event Registry component about the selected event and its registered handlers. The system displays this group box only if you select an event and click the Event Info button. To change any of this data, you must access the Event Registry component for the selected event.

Event Fields

Use this group box to enter values for each of the event fields that are part of the event that you are raising. The system does not perform any validation on the data that you enter in the Value fields. Be sure to enter the correct format for data values and use uppercase or lowercase values for character data as appropriate. The system makes these field values available to the event handlers as the context record for the event.

Click to jump to parent topicRaising Events

After you determine that an occurrence of the business event exists that the event in the Event Manager framework represents, you can raise the event in the Event Manager framework.

The Event Manager framework provides an API that creates and raises events. The API code is:

import EOEN_MVC:EOEN_MODEL:EOENInterface; Local EOEN_MVC:EOEN_MODEL:EOENInterface &myEvent; Local Record &recContext; &myEvent = create EOEN_MVC:EOEN_MODEL:EOENInterface("", 0); &recContext = &rsContextRec(1).GetRecord(Record.CONTEXT_REC); &myEvent.AddContextRecord(&recContext); &myEvent.RaiseEvent("EventName");

Pass the name of the event to the Event Interface, which returns an instance of the event object. Add the context record and then execute the RaiseEvent method on the event object.

Important! Instantiating an event object does not automatically raise the event. You must invoke the event's RaiseEvent method to raise the event and initiate subsequent Event Manager framework processing.

In the following example, assume that we have created an event called AssignmentMilitaryRankChanged. This event represents the business event of assigning or updating the military rank of a person's assignment (Job record) instance. Whenever the rank attribute of the assignment (Job record row) changes, we want to raise the event. Here is the pseudocode to add to the JOB_MIL.MIL_WORN_RANK:SavePostChange PeopleCode event for the Job component:

import EOEN_MVC:EOEN_MODEL:EOENInterface; /**********************************************************/ /* FUNCTION: GetPriorRank */ /* Inputs: &rsJOB As Rowset, &CurrentRow as number */ /* Returns: none */ /* */ /* Get Prior Worn Rank */ /**********************************************************/ Function GetPriorRank(&rsJOB As Rowset, &CurrentRow As integer,⇒ &PRIOR_ROW As integer, &PRIOR_RANK As string); Local date &PRIORDT = Date3(1900, 1, 1); Local integer &PRIORSEQ = 0; Local date &JOB_Effdt = &rsJOB(&CurrentRow).JOB.EFFDT.Value; Local integer &JOB_Effseq = &rsJOB(&CurrentRow).JOB.EFFSEQ.Value; Local integer &i; &PRIOR_ROW = 0; &PRIOR_RANK = " "; For &i = 1 To &rsJOB.RowCount; Local date &FETCH_EFFDT = &rsJOB(&i).JOB.EFFDT.Value; Local integer &FETCH_EFFSEQ = &rsJOB(&i).JOB.EFFSEQ.Value; If (&FETCH_EFFDT < &JOB_Effdt Or (&FETCH_EFFDT = &JOB_Effdt And &FETCH_EFFSEQ < &JOB_Effseq)) And (&FETCH_EFFDT > &PRIORDT Or (&FETCH_EFFDT = &PRIORDT And &FETCH_EFFSEQ > &PRIORSEQ)) Then &PRIORDT = &FETCH_EFFDT; &PRIORSEQ = &FETCH_EFFSEQ; &PRIOR_ROW = &i; End-If; End-For; If &PRIOR_ROW > 0 Then &PRIOR_RANK = &rsJOB(&PRIOR_ROW).GetRowset(Scroll.JOB_MIL)⇒ (1).JOB_MIL.MIL_WORN_RANK.Value; End-If; End-Function; /***************************************************************************/ /* FUNCTION: RaiseMilitaryRankEvent */ /* Inputs: JOB_MIL rowset, Current row */ /* Returns: none */ /* */ /* Check if MilitaryRankEvent event should be raised */ /* if a change has been done: */ /* - Worn rank changed */ /* - Row deleted and the worn rank is different from the previous one */ /* - Row inserted and the worn rank is different from the previous one */ /* the event will be raised */ /***************************************************************************/ Function RaiseMilitaryRankEvent(&rsJOB As Rowset) If INSTALLATION.MILITARY = "Y" Then Local integer &PRIOR_ROW; Local string &PRIOR_RANK; Local boolean &RaiseEvent = False; Local integer &i; For &i = 1 To &rsJOB.RowCount /* Get current Job row and Worn Rank value */ Local Row &rowJOB = &rsJOB.GetRow(&i); Local Rowset &rsJOB_MIL = &rowJOB.GetRowset(Scroll.JOB_MIL); /*************************/ /* Rank has been updated */ /*************************/ If &rsJOB_MIL(1).JOB_MIL.MIL_WORN_RANK.IsChanged Or (&rowJOB.JOB.EFFDT.IsChanged And Not &rowJOB.IsNew) Then If All(&rsJOB_MIL(1).JOB_MIL.MIL_WORN_RANK.Value) Then &RaiseEvent = True; Break; End-If; Else /***************/ /* New JOB row */ /***************/ If &rowJOB.IsNew Then /* Get previous Rank */ GetPriorRank(&rsJOB, &i, &PRIOR_ROW, &PRIOR_RANK); If &PRIOR_ROW > 0 Then If &rsJOB_MIL(1).JOB_MIL.MIL_WORN_RANK.Value <> &PRIOR_RANK And All(&rsJOB_MIL(1).JOB_MIL.MIL_WORN_RANK.Value) Then &RaiseEvent = True; Break; End-If; Else /* No previous Rank */ If All(&rsJOB_MIL(1).JOB_MIL.MIL_WORN_RANK.Value) Then &RaiseEvent = True; Break; End-If; End-If; Else /****************************/ /* JOB row has been deleted */ /****************************/ If &rowJOB.IsDeleted Then /* Get previous Rank */ GetPriorRank(&rsJOB, &i, &PRIOR_ROW, &PRIOR_RANK); If &PRIOR_ROW > 0 Then If &rsJOB_MIL(1).JOB_MIL.MIL_WORN_RANK.Value <> &PRIOR_RANK And All(&rsJOB_MIL(1).JOB_MIL.MIL_WORN_RANK.Value) Then &RaiseEvent = True; Break; End-If; Else /* No previous Rank */ If All(&rsJOB_MIL(1).JOB_MIL.MIL_WORN_RANK.Value) Then &RaiseEvent = True; Break; End-If; End-If; End-If; End-If; End-If; End-For; If &RaiseEvent Then Local EOEN_MVC:EOEN_MODEL:EOENInterface &myEvent; Local Record &recContext; &myEvent = create EOEN_MVC:EOEN_MODEL:EOENInterface("", 0); &recContext = &rsJOB_MIL(1).GetRecord(Record.JOB_MIL); &myEvent.AddContextRecord(&recContext); &myEvent.RaiseEvent("AssignmentMilitaryRankChanged"); End-If; End-If; End-Function; If GetLevel0()(1).GetRowset(Scroll.JOB).GetRow(CurrentRowNumber(1)).RowNumber = 1 Then RaiseMilitaryRankEvent(GetLevel0()(1).GetRowset(Scroll.JOB)); End-If;

The lines in the preceding code that deal with the action of raising the event are:

Local EOEN_MVC:EOEN_MODEL:EOENInterface &myEvent; Local Record &recContext; &myEvent = create EOEN_MVC:EOEN_MODEL:EOENInterface("", 0); &recContext = &rsJOB_MIL(1).GetRecord(Record.JOB_MIL); &myEvent.AddContextRecord(&recContext); &myEvent.RaiseEvent("AssignmentMilitaryRankChanged");

Important! During the course of raising an event, the framework causes certain tracking and logging information to be stored in the database. Because of this, events can be raised only from PeopleCode events that normally allow database updates. More specifically, events can be raised only from SavePreChange, SavePostChange, and Workflow PeopleCode events.

Click to jump to parent topicMonitoring Events

This section discusses how to:

Click to jump to top of pageClick to jump to parent topicPages Used to Monitor Events

Page Name

Definition Name

Navigation

Usage

Event Manager - Monitor

EOEN_EVENT_MON

Enterprise Components, Events & Notifications, Event Framework, Event Monitor

Review the status of raised or processed business events and their associated event handler executions.

Event Monitor - Handlers

EOEN_EVENT_MON2

Enterprise Components, Events & Notifications, Event Framework, Event Monitor

Click the Handlers link for an event instance on the Event Manager - Monitor page.

Review the details of registered event-handler executions on the local node for a selected event instance.

Event Monitor - Handler Exceptions

EOEN_EVENT_MON3

Enterprise Components, Events & Notifications, Event Framework, Event Monitor

Click the Handlers link for an event instance on the Event Manager - Monitor page.

Click the Display Exceptions button on the Event Monitor - Handlers page.

View the data, exceptions, and trace information that the selected event handler logged during execution and passed back to the Event Manager framework.

Click to jump to top of pageClick to jump to parent topicReviewing Event Instances

Access the Event Manager - Monitor page (Enterprise Components, Events & Notifications, Event Framework, Event Monitor).

Search Criteria

Enter the search criteria for retrieving event instances. At a minimum, you must select at least one criterion to retrieve results. Use the remaining fields to narrow your search results.

Find Event

Select the event from the local Event Registry component for which you want to review event instances.

Last

Specify the time period in which the event was raised. For remote events, this is the time period in which the event appeared in the local node. In the first box, specify a numeric quantity. Then select a time qualifier: Days, Hours, or Minutes.

Node

Select a node name to limit the search results to event instances of raised events within a specific node.

Refresh

Click to refresh the list of event instances after changing any of the search criteria.

Display Event Data

Select to display the event data for each event instance. The system displays the Event Data column in the Event Instances grid.

Event Instances

Review the logged event instances that meet your search criteria. The system displays instances for only the events and event handlers that you have configured in the local Event Registry component to be logged. You set the logging option for an event by selecting the Logging Enabled check box for an event on the Define Events page. Note that the process that raises the event waits for all registered synchronous event handlers to execute.

Node

The system displays the node from which the event instance was raised.

Event ID

The identification code of the event. The combination of this value and the node value uniquely identify the event instance on the originating node.

Event Name

The event name.

Event Created

The date and time that the event was raised in the source database (node). The system displays the time zone for this field because events could be raised in a node that operates in a time zone that differs from the local node.

User ID

The ID of the user that raised the event. This field is applicable only to event instances that are raised in the local database.

Event Data

The data for the event instance. To view the data, you must select the Display Event Data check box.

Handlers

Click this link for a specific event instance to access the Event Monitor - Handlers page, where you can view information about the registered event handlers that were executed on the local node for the selected event instance.

Click to jump to top of pageClick to jump to parent topicReviewing Event Handler Executions

Access the Event Monitor - Handlers page (click the Handlers link for an event instance on the Event Manager - Monitor page).

The system displays information for only the event handlers that you have configured to log executions. To log event handler executions, you must set the Logging option for a specific event handler and event combination on the Registered Handlers page.

The upper portion of the page displays information about the selected event instance that caused the event handler execution as well as the date and time that the local node began processing the event. For local events, the Processed date and time is generally the same as the date and time that the event was created. For remote events, the Processed date and time indicates when the local node received notification of the remote event from PeopleTools Integration Broker.

Handler Execution

This grid lists the event handlers that the system executed on the local database in response to the selected event instance.

If no event handler execution information is available, the system displays an informative message that indicates the possible reasons why no information is available. Possible reasons are that no event handlers are registered for the selected event, no event handlers are configured to log execution for the selected event, no synchronous event handlers are registered for the selected event and PeopleTools Integration Broker has not yet executed any asynchronous event handlers, or no event handlers executed for the event.

Event Handler

The system displays the full path of the application class that implements the event handler.

Handler Executed

The system displays the date and time that the system executed the event handler.

The system displays the event instance data.

The system displays information about the event handler exceptions.

The system displays the event handler exception warnings.

The system displays the event handler exception errors.

The system displays event-handler trace information. To view trace information, you must select the Trace check box on the Registered Handlers page for this event handler and event combination.

Click to jump to top of pageClick to jump to parent topicReviewing Event Handler Exceptions

Access the Event Monitor - Handler Exceptions page (click the Display Exceptions button on the Event Monitor - Handlers page).

The upper portion of the page displays information about the selected event instance that caused the event handler execution as well as the date and time that the local node began processing the event.

Events raised in a remote database are visible in the Event Monitor component only after the local node receives and processes the asynchronous event message, and only if you have enabled logging for the event when registering the event in the local database through the Event Registry component.

Note. If you inactivate the PeopleTools Integration Broker Service Operation for the generic event message, then the local Event Manager framework does not process any remote events and thus no remote events will be visible in the Event Monitor component.

Handler

The system displays the full path of the application class that implements the event handler.

Display

Select a value to filter the type of information that displays on the page.

Possible values are All Entries, Exceptions, Event Data, and Trace Entries. The system displays the information that is produced by the event handler in the order in which the event handler produced the information.

The system displays the event instance data.

The system displays information about the event handler exceptions.

The system displays the event handler exception warnings.

The system displays the event handler exception errors.

The system displays event-handler trace information. To view trace information, you must select the Trace check box on the Registered Handlers page for this event handler and event combination.

Click to jump to parent topicViewing Event Summaries

This section discusses how to:

Click to jump to top of pageClick to jump to parent topicPages Used View Event Summaries

Page Name

Definition Name

Navigation

Usage

Event Manager - Event Summary

EOEN_EVENT_SUM

Enterprise Components, Events & Notifications, Event Framework, Event Summary

View a summary of all the logged event instances in the local database. This is useful for quickly identifying problems, such as researching the cause of failed event-handler executions to determine a resolution.

Event Manager - Failed Handlers

EOEN_EVENT_SUM2

Click the Failed Handlers link for an event handler on the Event Manager - Event Summary page.

View a list failed event handlers across all instances of a selected event and node combination.

Event Monitor - Handler Exceptions

EOEN_EVENT_MON3

Click the Details button for a failed event handler on the Event Manager - Failed Handlers page.

View the exceptions that failed event handlers produced.

Click to jump to top of pageClick to jump to parent topicViewing a Summary of Event Instances

Access the Event Manager - Event Summary page (Enterprise Components, Events & Notifications, Event Framework, Event Summary).

Refresh

Click to refresh the statistics that the system displays on this page. The option to refresh is useful in production environments in which the raising and processing of events occurs frequently.

Summary Grid

Use this group box to review statistics for every event that has logged instances in the local database. The system displays event instances for only the events that are configured for logging through the Event Registry component in the local database. The system groups the logged event instances by event and node combination.

Event Name

The system displays the name of the event for which the system logged event instances for the event and node combination.

Node Name

The name of the originating node from which the system raised the event instances for the event and node combination.

Event Instances

The number of event instances that the system logged for the event and node combination. This equates to the number of times that the system raised the event.

Handler Executions

The total number of event handlers that the system has executed for the corresponding event and node combination.

Failed Handlers

The total number of event handlers that the system executed for the corresponding event and node combination that returned a failed status. The system displays this number as a link. Click the link to access the Event Manager - Failed Handlers page, where you can view a list of failed event handlers across all instances of the event and node combination. From that page you can view the exceptions that the failed event handlers produced.

Click to jump to top of pageClick to jump to parent topicViewing Failed Event Handlers

Access the Event Manager - Failed Handlers page (click the Failed Handlers link for an event handler on the Event Manager - Event Summary page).

The system lists information about each failed event handler. Click the Details button to access the Event Monitor - Handler Exceptions page, where you can view the exceptions that the failed event handlers produced.

Click to jump to top of pageClick to jump to parent topicViewing Exceptions for Failed Handlers

Access the Event Manager - Handler Exceptions page (click the Details link for an event handler on the Event Manager - Failed Handlers page).

Details for the exception are displayed.