uCosminexus Application Server, EJB Container Functionality Guide
This subsection explains the operations of the EJB timer and callback in the following cases:
The operations differ according to the types of timers.
When a past time is specified in the EJB timer, call back the timeout method once immediately after the generation of the EJB timer, in the case of a single-event timer. In the case of an interval timer, call back the timeout method during the timeout that occurs after the generation of the EJB timer. The following figure shows the operations when a past time is specified in the EJB timer:
Figure 2-26 Operation when a past time is specified in the EJB timer
The operations when you specify a past date and time in a calendar format or specify an invalid value as the date and time (such as 2/31) are as follows:
The message KDJE43211-W is output when you invoke the getNextTimeout method.
When there are multiple EJB timers for one Enterprise Bean class, the callback processing is executed concurrently if callback of these multiple EJB timers overlap. The callback threads and the Enterprise Bean instances for which processing can be performed concurrently are, however, restricted in certain cases. If such callback threads and instances are not present, wait until the release of the threads and the instances.
Only one callback can be executed at a time in a single EJB timer. Depending upon the processing contents, the processing of the timeout method may sometimes take longer. As a result, in the case of an interval timer, the time of the next timeout elapses during execution of the callback processing and the time of multiple timeouts may elapse until one callback finishes. In such a case, the callback processing that could not be performed as per the timeout time is not executed, but callback processing is executed for the timeout that occurs after the time of completion of the previous callback.
The following figure shows the operations when the previous callback has not finished during current callback:
Figure 2-27 Operations when the previous callback has not finished during current callback
In this figure, the setting is such that timeout occurs at an interval of one minute and the callback processing is executed. When the time for the second and the third timeout elapses during processing of the first callback, the second callback processing will be performed at the next timeout after completion of the first callback processing (that is the scheduled time for the fourth timeout). The callback processing is not performed twice for the timeout that has elapsed the timeout time.
When the EJB timer cancellation method of the same EJB timer is invoked concurrently from multiple threads, cancellation is executed sequentially.
If, however, EJB timer cancellation is executed under the transaction management, it is not possible to verify whether the EJB timer is deleted until the transaction is concluded. As a result, if some other thread cancels the same EJB timer, it results in exclusive waiting.
The following figure shows the operations when cancellation of the same EJB timer is invoked concurrently from multiple threads:
Figure 2-28 Canceling the EJB timer invoked from multiple threads
When EJB timer cancellation method is invoked during the execution of callback of the timeout method, the operation is as follows:
Figure 2-29 Cancellation during execution of callback
Figure 2-30 Cancellation of EJB timer in the timeout method
For an unconcluded transaction A in which the EJB timer is cancelled, the callback processing of the timeout method waits exclusively from the time of completion of callback until the transaction A is concluded. Therefore, when the timeout method is under the management of a CMT transaction, the conclusion of the transaction will be in the waiting state until the transaction A is concluded. The following figure shows the flow of processing in such a case:
Figure 2-31 Callback operations when an unconcluded transaction with the EJB timer cancelled
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.