Deleting a scheduled service within a composite

Often, scheduled jobs that we create dynamically are temporary in nature. So, once created, we need the ability to delete them when no longer required.

Getting ready

For the purpose of this recipe, we will delete the scheduled job created in the previous recipe. So, you will need to complete that recipe before starting this.

Create an SOA application, with a project containing an empty composite (named CancelParcelTracker in the example detailed in this recipe).

The CancelParcelTracker composite is designed to receive a request containing the orderNo for a parcel that is being tracked and to delete the corresponding scheduled job.

How to do it...

  1. Within CancelParcelTracker, create an external reference to the Scheduler, as described in steps 1-3 of the previous recipe.
  2. Next, drag an Invoke activity onto our BPEL process. Double-click on it to open the Edit Invoke window. Give it the name removeJob, select Scheduler for the Partner Link, and select the operation removeJob.

    For the input variable, click on the auto-create variable (plus icon) to launch the Create Variable window. Give the variable a meaningful name (for example, removeJob Input). Do the same for the output variable.

  3. Drag an Assign activity onto our BPEL process just before the Invoke activity. Double-click on it to open the Edit Assign window, and give it the name setRemoveJob.
  4. We need to populate the job element with the unique identity of the job. This is a composite key defined by the elements jobId and jobGroup.

    Use the Assign activity to set jobId to contain the orderNo of the parcel being tracked and to set the jobGroup to ParcelTracker.

  5. Now that our process is complete, deploy it and run it to delete the job we created in the previous recipe.

    You should see that no more instances of the ParcelTracker composite are created.

How it works...

Removing a scheduled job is as simple as invoking the Scheduler's removeJob operation with a request message that includes our job's key values as follows:

<?xml version="1.0" encoding="UTF-8"?>
<removeJob xsi:schemaLocation="http://rubiconred.com/evs/util.sch.Job util.sch.evs.Job_1.0.xsd" xmlns="http://rubiconred.com/evs/util.sch.Job" xmlns:job="http://rubiconred.com/ebo/util.sch.Job" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <body>
    <job:jobId>120699</job:jobId>
    <job:jobGroup>ParcelTracking</job:jobGroup>
  </body>
</removeJob>
..................Content has been hidden....................

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