The ScheduledOrderService
is the back-end service that polls the Order Repository at a periodic interval and submits scheduled Orders
according to their schedules.
When an application that includes ATG Commerce deploys, a PlaceScheduledOrders
task is scheduled with the /atg/dynamo/service/Scheduler
. This scheduled task is run at the interval specified in ScheduledOrderService.schedule
. When the scheduled task is run, the Scheduler
calls ScheduledOrderService.performScheduledTask()
. The ScheduledOrderService
then attempts to obtain a global write lock from the server lock manager. If the lock is obtained successfully, then it calls doScheduledTask()
.
At a general level, the ScheduledOrderService.doScheduledTask()
method polls the Order Repository for all scheduled Orders
that should be checked out. For each scheduled Order
it finds due for checkout, it then clones the template Order
associated with the scheduled Order
, checks out the cloned Order
, and sets the nextScheduledRun
property of the scheduled Order
to the next date and time it should be checked out. If an error occurs when processing an individual scheduled Order
, then a CommerceException
is thrown, the state of the scheduled Order
is set to Error, and the state of the cloned Order
is set to PENDING_MERCHANT_ACTION. However, the remaining scheduled Orders
are processed.
The following table describes the various methods of ScheduledOrderService
that support this process:
Method | Description |
---|---|
| Called when the The Note: Be aware that the defined interval specified in |
| Calls |
| Processes all scheduled This method calls |
| Uses the query defined in the |
| Processes the current scheduled This method calls If the scheduled |
| Sets the next time that the scheduled |
| This method checks out the current scheduled First, the template Second, Third, the template Fourth, if the Fifth, the cloned Finally, the cloned |
| Reprices the cloned |
ATG Commerce provides an instance of class atg.commerce.order.scheduled.ScheduledOrderService
, which extends atg.service.scheduler.SingletonSchedulableService
. It is located in Nucleus at /atg/commerce/order/scheduled/ScheduledOrderService
.
Class atg.service.scheduler.SingletonSchedulableService
enables multiple ATG Commerce servers to run the same scheduled service, while guaranteeing that only one instance of the service will perform the scheduled task at any given time. This provides a degree of protection from server failures, since the loss of any single ATG Commerce server will not prevent the scheduled service from running on some other ATG Commerce server.
To use a SingletonSchedulableService
like ScheduledOrderService
on multiple ATG Commerce instances, you must run a server lock manager and point all client lock managers at it. For more information on SingletonSchedulableService
, see the Scheduler Services section of the Core Dynamo Services chapter in the ATG Programming Guide.