6.6.8. Loop Control Handler in Request Thread

This handler repeatedly executes the subsequent handlers until there is a request to stop the process. This handler is used in the process that monitors the message queue and table on the database and processes the unprocessed data as and when needed.

Tip

Each request (data) is handled independently in the process that processes and monitors the message queue and the table on the database. Even if one request process causes an error, other request processes must be continued. Therefore, exceptions caught by this handler continue the process except when there is normal process termination request or in the case of some fatal exceptions.

For details, see Process content according to the exception (error) that occurs in the subsequent handler.

This handler performs the following processes.

The process flow is as follows.

../../../../_images/flow24.png

6.6.8.2. Module list

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

6.6.8.3. Constraints

Place this handler after the Retry Handler
This handler throws Retryable exception for exceptions where processing can be continued. Therefore, this handler must be configured after the Retry Handler, which processes the retriable exceptions.

6.6.8.4. Configure the wait time for service shutdown

Wait time can be configured when the exception (ServiceUnavailable) indicating service shutdown is thrown by a subsequent handler. The check timing of whether the service is open can be adjusted by configuring this time.

If a long wait time is configured, the problem of the process not starting immediately even if there is a change in service while it is open may occur. Hence configure a value as per the requirement. If this configuration is omitted, the subsequent handler will be re-executed after waiting for 1 second.

A configuration example is shown below.

<component class="nablarch.fw.handler.RequestThreadLoopHandler">
  <!-- Configure 5 seconds for wait time -->
  <property name="serviceUnavailabilityRetryInterval" value="5000" />
</component>

Tip

If Service Availability Check Handler is not configured in the subsequent handler, it is not necessary to configure this configuration value. (even if configured, this value will not be used)

6.6.8.5. Method to stop this handler

This handler repeatedly delegates the process to subsequent handlers until an exception indicating process stop request occurs. When it is necessary to stop the process for maintenance, etc., the Process Stop Control Handler must be configured after this handler so that the process can be stopped from the outside.

Refer to Process content according to the exception (error) that occurs in the subsequent handler for the process contents when an exception indicating a process stop request occurs.

6.6.8.6. Process content according to the exception (error) that occurs in the subsequent handler

The process contents performed by this handler according to the exceptions (errors) that occur in the subsequent handler is described.

Exception during service shutdown (ServiceUnavailable)
After waiting for a certain period, the process is again delegated to the subsequent handler. For the method to configure the wait time, see Configure the wait time for service shutdown.
Exception indicating process stop request (ProcessStop)
Since the exception indicates the process stop request, processing of this handler is terminated.
Exception indicating abnormal termination of the process (ProcessAbnormalEnd)
Rethrows the exception caught as the exception indicates abnormal termination of the process.
Service error indicating that the process could not be continued (ServiceError)
Delegates the log output process to the exception class that is caught and throws Retryable exception.
Exception indicating abnormal termination of the handler process (Result.Error)
Outputs FATAL level log, and throws Retryable exception.
Runtime exception (RuntimeException)
Outputs FATAL level log, and throws Retryable exception.
Exception indicating thread stop (ThreadDeath)
Outputs INFO level log and rethrows the exception that is caught (ThreadDeath).
Stack overflow error (StackOverflowError)
Outputs FATAL level log, and throws Retryable exception.
Insufficient heap error (OutOfMemoryError)

Outputs a message indicating that insufficient heap has occurred to the standard error output and then outputs a FATAL level log. (Since there is possibility of insufficient heap occurring again during log output, the log is output after the output of the standard error message.)

Since there is possibility that the process can be continued by removing the reference to the object that caused insufficient heap, Retryable exception is thrown.

Error indicating JVM error (VirtualMachineError)
Rethrows the exception that is raised
Error other than the above
Outputs FATAL level log, and throws Retryable exception.