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.
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.
CancelParcelTracker
, create an external reference to the Scheduler, as described in steps 1-3 of the previous recipe.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.
setRemoveJob
.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
.
You should see that no more instances of the ParcelTracker
composite are created.
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>