This sample demonstrates how to retrieve a step element from a queue, set the comments on the step element, display the step information, and complete the step. Run the sample by entering a command similar to the following:
java StepProcessorSample username password <server name>:<port
number>/<router instance name> [output_filename]
Note For a detailed explanation of the command line, see the Run the sample application section of the Run the Unmodified Samples topic.
The StepProcessorSample class contains two methods: the main(String args[]) method and the StepProcessorSample(VWSession vwSession, Logger logger, String queueName) method, which is the constructor.
The main method uses common techniques for validating and defaulting argument values. The default value for the log output file is StepProcessorSample.out. The main method constructs and passes vwSession and Logger objects to the sample constructor. Main() handles the login and logoff for the session with the login() and logoff() methods of the sample SessionHelper class. It provides workflow logging with an instance of the sample Logger class. The main method passes the session, the logger, the user name, and the queue name to the constructor method.
The constructor StepProcessorSample(VWSession, Logger, String) performs common exception handling and retrieves a step element from a queue with the sample method queueHelper.getQueue(). It demonstrates setting the comments on the step element, displaying the step information, and dispatching the step with VWStepElement methods. The code to perform this is organized as follows:
Create an instance of the local sample QueueHelper class, and then create the object for the requested queue:
queueHelper = new QueueHelper(vwSession, logger);
// get the requested queue
vwQueue = queueHelper.getQueue(queueName);
if (vwQueue != null)
{
Get a step element from the queue object:
vwStepElement = queueHelper.getStepElement(vwQueue);
if (vwStepElement != null)
{
Lock the record whenever the step element changes:
vwStepElement.doLock(true);
Set the comments:
vwStepElement.setComment("This
is the user's comment.");
Display the Step Processor information:
logger.displayStepElementInfo(vwStepElement);
Dispatch the step:
logger.log("Completing
step: " + vwStepElement.getOperationName());
vwStepElement.doDispatch();
}
}