Friday, August 26, 2011

Programming a Schedule Job !!! Dynamic job

I find dynamic schedule jobs a very useful feature in Websphere commerce. It is very useful for jobs that require to be dynamically generated based on some programming logic in a command. e.g. if there are emails that need to be triggered based on a event or any admin action that requires a schedule job to run to generate reports.

AddJobCmd addJobCmd =
(AddJobCmd) CommandFactory.createCommand(
AddJobCmd.class.getName(),
commandContext.getStoreId());
addJobCmd.setQueryString();
addJobCmd.setForUserId();
addJobCmd.setStartTime();
addJobCmd.setPathInfo("");
addJobCmd.setUrl(); //Even though this is not checked in validate parameters, this is required
addJobCmd.setStoreId(new Integer(SITE_STORE));
addJobCmd.setCommandContext(commandContext);
addJobCmd.setAccCheck(false);
addJobCmd.execute();
addJobCmd.setAccCheck(true);


recurring Jobs needs these extra methods to be configured:

addJobCmd.setAttempts()
addJobCmd.setDelay()
addJobCmd.setInterval()


7 comments:

  1. Hi,

    Found your blog very useful, just a small request:-

    Lot of times in interview I have been asked the sequence in which the out of box commands and task commands are called for flows like ordering , logging in and other common flows . I tried a lot but i have not been able to decode the exact sequence. It will be very beneficial for me and lot of other readers of this blog if you can write a dedicated blog on this sequence.

    ReplyDelete
  2. I will write something on the sequence of controller command task commands for Order flow and Login\Registration flow.

    ReplyDelete
  3. This is already done,
    http://www.ibmwcs.com/2011/09/order-login-flow-commands.html

    ReplyDelete
  4. Hi, This is useful info. Is there any way to programatically, know if an instance of this job is already running. I need to implement something like: schedule a job if it is not already running.

    Thanks In Advance!

    ReplyDelete
  5. which parameter should be used to execute custom controller command.. I mean I have to execute a custom command in asynchronous manner what parameters should be set in AddJobCmd

    ReplyDelete
  6. This process up may take the form of keyword selection in a search engine or any number of methods with point and click directories. It's important for contractors to study the job posting and keyword guidelines of the hosting job board since they will differ from site to site.guarantor

    ReplyDelete