6.7.1. Process Resident Handler

A handler that repeatedly executes the contents of subsequent handler queues at regular intervals. This handler periodically monitors the input data of a specific data source and performs batch processing and is used in the so-called resident startup type batch process.

This handler performs the following processes:

The process flow is as follows.

../../../../_images/flow1.png

6.7.1.2. Module list

<dependency>
  <groupId>com.nablarch.framework</groupId>
  <artifactId>nablarch-fw-standalone</artifactId>
</dependency>

6.7.1.3. Constraints

This handler must be configured after the retry handler.
If a runtime exception is caught by this handler, rethrows after wrapping it with a retryable exception ( RetryableException ) and delegates the process continuation control to retry_handler. Therefore, this handler must be configured after the retry handler.

6.7.1.4. Configure the data monitoring interval

Data monitoring interval is configured in milliseconds in the dataWatchInterval property. The default value when the configuration is omitted is 1000 milliseconds (1 second).

An example is shown below.

<component name="settingsProcessResidentHandler"
    class="nablarch.fw.handler.ProcessResidentHandler">

  <!-- Configure 5 seconds (5000) for data monitoring interval -->
  <property name="dataWatchInterval" value="5000" />
  <!-- Other properties are omitted -->
</component>

6.7.1.5. How to terminate the process resident handler

This handler stops subsequent handler calls and terminates processing if an exception indicating the normal termination of the process has been thrown. By default, this handler ends when the Process Stop Control Handler processing stop exception ( ProcessStop (including subclasses)) is thrown.

To change the exception that indicates successful completion of a process, configure the normalEndExceptions property to a list of exception classes. When the exception list is configured, the default configuration is overwritten, and ProcessStop has to be configured without fail.

An example is shown below.

<component name="settingsProcessResidentHandler"
    class="nablarch.fw.handler.ProcessResidentHandler">

  <!-- Exception list indicating the normal termination of the process -->
  <property name="normalEndExceptions">
    <list>
      <!-- Exception class indicating default process stop of Nablarch -->
      <value>nablarch.fw.handler.ProcessStopHandler$ProcessStop</value>
      <!-- Exception class indicating project custom process stop (subclasses are also covered) -->
      <value>sample.CustomProcessStop</value>
    </list>
  </property>

  <!-- Other properties are omitted -->
</component>

6.7.1.6. Handling exceptions that occur in subsequent handlers

In this handler, processing is switched between continuation or termination depending on the type of exception that has occurred in the subsequent handler.

The following shows the processing details of each exception.

Exception during service shutdown( ServiceUnavailable )
In the case of an exception during service shutdown, executes the subsequent handler again after waiting for the time set in the data monitoring interval.
Retryable exception
In the case of retryable exception ( RetryUtil#isRetryable() returns true), rethrows the exception that is caught without doing anything.
Exception that terminates the process abnormally

For exceptions indicating abnormal termination, rethrows the caught exception without doing anything.

Configure exceptions that terminates the process abnormally to the abnormalEndExceptions property. By default, ProcessAbnormalEnd (including subclasses) is the target class for abnormal termination.

Exception that terminates the process normally

The process ends with the result object returned from the subsequent handler as the return value of this handler.

See How to terminate the process resident handler for the exception that terminates the process normally.

Exceptions other than the above
Records the exception information in the log, and rethrows after wrapping with retryable exception ( RetryableException ).