executeBatch
executeBatch(String sessionID, CommandImpl[] commands)
The executeBatch method enables you to execute several methods with a single request to the runtime server.
*
sessionID-A string identifying the session ID. This session ID is used for all commands run by this method call.
*
commandImpl[]-An array of CommandImpl objects, one for each command you want to perform.
The result of calling this method is equivalent to explicitly calling each method in the Command array. This method minimizes the number of actual requests to the runtime server. The runtime server runs each method serially; for each call, any error or warnings are captured in the Response object that corresponds to that method call. If an error is encountered, the executeBatch continues with the rest of the calls in the batch. If the running of any method results in an error, the top level status for the BatchResponse object reflects that error. If no error occurred, the top level status reflects any warnings that may have occurred. If no warning occurred, then the top level status reflects a successful run of the batch.
Return value
The runtime server responds to the executeBatch with a BatchResponse object.
Example
The following example shows how to call all the getOffer and postEvent methods with a single executeBatch call, and a suggestion for how to handle the response.

/** Define all variables for all members of the executeBatch*/
String sessionId="MySessionID-123";
String interactionPoint = "Overview Page Banner 1";
int numberRequested=1;
String eventName = "logOffer";

/** build the getOffers command */
Command getOffersCommand = new CommandImpl();
getOffersCommand.setMethodIdentifier(Command.COMMAND_GETOFFERS);
getOffersCommand.setInteractionPoint(interactionPoint);
getOffersCommand.setNumberRequested(numberRequested);

/** build the postEvent command */
Command postEventCommand = new CommandImpl();
postEventCommand.setMethodIdentifier(Command.COMMAND_POSTEVENT);
postEventCommand.setEventParameters(postEventParameters);
postEventCommand.setEvent(eventName);

/** Build command array */
Command[] commands =
{
getOffersCommand,
postEventCommand,
};

/** Make the call */
BatchResponse batchResponse = api.executeBatch(sessionId, commands);

/** Process the response appropriately */
// Top level status code is a short cut to determine if there
// are any non-successes in the array of Response objects
if(batchResponse.getBatchStatusCode() == Response.STATUS_SUCCESS)
{
System.out.println("ExecuteBatch ran perfectly!");
}
else if(batchResponse.getBatchStatusCode() == Response.STATUS_WARNING)
{
System.out.println("ExecuteBatch call processed with at least one warning");
}
else
{
System.out.println("ExecuteBatch call processed with at least one error");
}

// Iterate through the array, and print out the message for any non-successes
for(Response response : batchResponse.getResponses())
{
if(response.getStatusCode()!=Response.STATUS_SUCCESS)
{
printDetailMessageOfWarningOrError("executeBatchCommand",
response.getAdvisoryMessages());
}
}