Scheduling services

A common requirement is to schedule a process or service to run at regular intervals, for example, we have an account billing composite that is required to be run once every night.

The Oracle SOA Suite doesn't provide a native scheduling component, so a common approach is to implement a BPEL process that continuously loops, with the sole purpose of launching another scheduled BPEL process.

However, as the process never dies, this will result in an ever-increasing audit trail, causing the objects persisted in the database, as well as the in-memory size of the process to grow over time, which eventually will have a negative impact on the performance of the engine.

A better approach is to use a Web Service Scheduler deployed to the Oracle SOA Suite.

Getting ready

You will need to download the Scheduler from the Rubicon Red website, which can be found at http://www.rubiconred.com/scheduler.

Once downloaded, follow the instructions to install the Scheduler on the WebLogic server running SOA Suite.

We are going to schedule the StockService process to run every hour, on the hour. This is a process that checks the stock levels for fast-selling titles and raises alerts if they are falling too low.

For the purpose of this demo, we have included a light-weight application, called StockApp, within the Getting ready samples for this recipe. You will need to open it in JDeveloper and deploy to the Oracle SOA Suite to follow along with this recipe.

How to do it...

  1. Log in to Oracle Enterprise Manager and open the StockService dashboard. Click on the Show WSDL and Endpoint URI icon (circled in the following screenshot). Log in to Oracle Enterprise Manager (EM) and open a window that contains the URI for the Stock Service WSDL.

    Highlight the WSDL URL and copy it, as we will need this in a moment.

    How to do it...
  2. Log into the Scheduler at http://<hostname>:7001/SchedulerUi/SchedulerUIExt.html.

    This will take you to the Scheduler dashboard. Click on the Add Job icon; this will open the Edit Job page. Enter the following information:

    Field

    Value

    Job Name

    Stock Check

    Job Group

    Stock

    Schedule Type

    Cron

    Active

    Ensure this is checked, otherwise the job won't be triggered.

    From

    Don't specify a value

    Until

    Don't specify a value

    Cron Expression

    0 * * * * ?

  3. For the Job type field, ensure Web service is selected, and then within WSDL, paste the URL for the WSDL specified in step 1 and hit Enter. The Scheduler will parse the WSDL, and assuming it is valid, will display details of the binding and service endpoints.
  4. From the Operation dropdown, select the checkInventory operation. This will populate the Payload field with a skeleton of the payload to be included, when the Scheduler invokes the web service. Update the content of the element WarehouseId to be Main, as shown in the following screenshot:
    How to do it...

    Once complete, click on Save. This will save the details of the job and return you to the dashboard.

    How to do it...

    The job will now be active.

  5. Log in to Enterprise Manager. Within the audit trail, we should be able to see an instance of the StockService process being created every 60 seconds.

How it works...

We have defined the job Stock Check in the Stock group with a cron schedule of 0 * * * * ?.

This will create a Quartz job, under the covers, that fires every minute on the minute. When it triggers, it will cause the Scheduler to submit a web service request to the specified endpoint containing the payload that we defined.

There's more...

The Scheduler can be used to schedule synchronous and asynchronous web services deployed to the Oracle SOA Suite or Oracle Service. In addition, it can be used to schedule the publication of EDN events to the SOA Suite.

While cron expressions are powerful, they can be confusing. So, the Scheduler also supports the creation of Simple Schedules, which are simpler to understand.

The Scheduler also comes with a web service API that enables us to create schedules dynamically from within another service, which we will look at in the next couple of recipes.

This is also useful for deployment purposes, as we can use this to create scheduled jobs as part of the process of deploying composites to the SOA Suite.

..................Content has been hidden....................

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