Performing custom actions after a process completes

You can use Process Completion Monitor processing to launch custom actions after a work queue or batch process completes a batch of items. For example, you might want to start the writer of a follow-on work queue during nightly batch processing.

Process Completion Monitor processing runs at schedulable intervals and examines the ProcessHistory table for all completed work queues and batch processes.

For each completed work queue that it finds, Process Completion Monitor:

  • Determines if all the work items in that work queue have either completed or failed.
  • Calls the IBatchCompletedNotification plugin implementation on a process if the process is complete and has no remaining available or checked-out work items.
  • Sets ProcessHistory.NOTIFICATIONSENT to true to invoke the IBatchCompletedNotification plugin implementation a single time only for any given process.

The IBatchCompletedNotification interface has a completed method that you can override to perform specific actions if a work queue or batch process finishes a batch of work. The parameters of the completed method are the ProcessHistory entity and the number of failed items. PolicyCenter considers work queue processing as complete if no work items remain on the queue, other than work items that failed. PolicyCenter considers a batch process as complete if the process stopped and its process history is available.

Schedule the Process Completion Monitor batch process

The Process Completion Monitor process runs at schedulable intervals and examines the ProcessHistory table for all completed work queues and batch processes.

About this task

In the base configuration, Guidewire does not schedule the Process Completion Monitor process. To enable this process, you need to add the process to file scheduler-config.xml.

Procedure

  1. In the Guidewire Studio Project window, expand configuration > config > scheduler.
    1. Open scheduler-config.xml.
    2. Add the following <ProcessSchedule> element:
      <ProcessSchedule process="ProcessCompletionMonitor">
        <CronSchedule minutes="*/5"/>
      </ProcessSchedule>
  2. Save your changes.

Implement the IBatchCompletedNotification interface

The Process Completion Monitor calls the IBatchCompletedNotification plugin implementation on a process if the process is complete and has no remaining available or checked-out work items.

Procedure

  1. In the Guidewire Studio Project window, expand configuration > gsrc.
  2. Do one of the following:
    • If a package for your plugin implementation classes already exists within gsrc, navigate to that package, then skip to step 6.
    • If a package for your plugin implementation classes does not exist, continue to step 3.
  3. Right-click gsrc, then click New > Package.
  4. Enter a package name, such as workqueue.
  5. Right-click your implementation class package and click New > Gosu Class.
  6. Enter the name IBatchCompletedNotification for the gosu class.
  7. Click OK.
  8. Define your Gosu class, using the following framework:
    package myCompany.plugin.workqueue
    uses gw.plugin.workqueue.IBatchCompletedNotification
    
     class IBatchCompletedNotification implements IBatchCompletedNotification {
    
       construct() { }
    
       override function completed(batch : ProcessHistory, numFailed : int) {
    
         //do something
        
        return
      }
    }
  9. Save your work.

Register a custom batch notification plugin

After you create your IBatchCompletedNotification plugin implementation, you need to register the plugin with PolicyCenter.

Procedure

  1. In the Guidewire Studio Project window, expand configuration > config > Plugins.
  2. Right-click registry and click New > Plugin.
  3. In the Plugin dialog, enter IBatchCompletedNotification for the name of your plugin.
  4. In the Plugin dialog, click
  5. In the Select Plugin Class dialog, type IBatchCompletedNotification and select the IBatchCompletedNotification interface.
  6. In the Plugin dialog, click OK.
    Studio creates a GWP file under Plugins > registry with the name that you entered.
  7. Click the Add Plugin icon and select Add Gosu Plugin.
  8. For Gosu Class, enter your class, including the package.
  9. Save your changes.