Calling asynchronous Services from HTML forms

You can use WebTools and HTML forms to run a Service asynchronously either one time or on a recurring basis. The following demonstrates the steps necessary to schedule testScv to be executed one time, asynchronously, as a scheduled job.

Getting ready

Navigate directly to the Schedule Job web page.

~https://localhost:8443/webtools/control/scheduleJob

How to do it...

To execute testScv asynchronously follow, these steps:

  1. In the Service form field, enter in testScv as shown in the screenshot.
  2. Leave the Job field empty. OFBiz will pick a unique name automatically.
  3. Use the calendar pop-up icon directly next to the Start Date/Time field to select any date and time after the current wall clock time.
    How to do it...

    Field

    Usage

    Pool

    By default, only one thread pool, called pool, is configured. To add more thread pools, see the serviceengine.xml file.

    Frequency

    A frequency of None tells OFBiz to run this Service once.

    Interval

    Interval is used with frequency to indicate how many times to invoke the Service.

    Count

    -1 indicates forever.

    Any valid integer is acceptable here.

  4. Submit this form by clicking the Submit button to bring up the Service Parameters form, which allows the caller to provide alternative input parameters to the Service.
  5. Add INPUT parameters as shown:
    How to do it...
  6. Submit the Service Parameters form. testScv will be scheduled to run at the specified time.

How it works...

Scheduled Services are run asynchronously from the calling program. As such, requests for scheduling are handled by the OFBiz job scheduler. Each scheduled Service is assigned a unique job identifier (jobId) and execution pool by the job scheduler. After the Service is scheduled for execution, control returns to the calling program.

There's more...

Using the OFBiz job scheduler Job List web page, you may find all scheduled jobs. In the following screenshot, testScv is shown as scheduled for execution on the Job List Search Results web page as specified in the recipe:

There's more...

Because the testScv only writes output to the logfile, we may verify successful execution and scheduling by observing the ofbiz.log runtime logfile as shown:

There's more...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.221.133