executeBatch
executeBatch(String sessionID, CommandImpl[] commands)
executeBatch 메소드를 사용하여 런타임 서버에 대한 단일 요청으로 몇 개의 메소드를 실행할 수 있습니다.
*
sessionID - 세션 ID를 식별하는 문자열입니다. 세션 ID는 이 메소드 호출에 의해 실행되는 모든 명령에 사용됩니다.
*
commandImpl[] - 수행할 각 명령에 대해 하나씩 CommandImpl 오브젝트의 배열입니다.
이 메소드 호출의 결과는 Command 배열의 각 메소드를 명시적으로 호출하는 것과 같습니다. 이 메소드는 런타임 서버에 대한 실제 요청 수를 최소화합니다. 런타임 서버는 각 메소드를 순차로 실행합니다. 각 호출에 대해 오류 또는 경고가 해당 메소드 호출에 대응하는 Response 오브젝트에 캡처됩니다. 오류가 발생하면, executeBatch가 일괄처리로 나머지 호출을 계속합니다. 메소드 실행 결과 오류가 발생하면, BatchResponse 오브젝트의 최상위 레벨 상태가 해당 오류를 반영합니다. 오류가 발생하지 않은 경우, 최상위 레벨 상태는 발생했을 수도 있는 경고를 반영합니다. 경고가 발생하지 않은 경우, 최상위 레벨 상태는 성공한 일괄처리 실행을 반영합니다.
리턴 값
런타임 서버는 BatchResponse 오브젝트로 executeBatch에 응답합니다.
다음 예는단일 executeBatch 호출로 getOffer 및 postEvent 메소드를 모두 호출하는 방법과 응답 처리 방법에 대한 제안을 표시합니다.
/** 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());
}
}