Showing posts with label websphere commerce ibm schedule jobs dynamic addjobcmd. Show all posts
Showing posts with label websphere commerce ibm schedule jobs dynamic addjobcmd. Show all posts

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()