* @throws SCServiceException
* the SC service exception
*/
private SCManagedMessage pollAppendices(int operationTimeoutSeconds, int nrOfAppendix, String cacheId)
throws SCServiceException {
SCManagedMessage managedMsg = new SCManagedMessage();
managedMsg.setCachingMethod(SC_CACHING_METHOD.INITIAL);
SCMPClnExecuteCall clnExecutePollCall = new SCMPClnExecuteCall(this.requester, this.serviceName, this.sessionId);
clnExecutePollCall.setCacheId(cacheId);
// appendices need to be read from cache
for (int readApp = 1; readApp <= nrOfAppendix; readApp++) {
clnExecutePollCall.setAppendixNr(readApp);
SCServiceCallback cbk = new SCServiceCallback(true);
try {
clnExecutePollCall.invoke(cbk, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
} catch (Exception e) {
throw new SCServiceException("Execute poll request failed. ", e);
}
// 3. receiving reply and error handling
SCMPMessage reply = cbk.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
if (reply.isFault()) {
SCServiceException scEx = new SCServiceException("Execute poll failed.");
scEx.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
scEx.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
throw scEx;
}
SCAppendMessage appendix = new SCAppendMessage();
appendix.setData(reply.getBody());
appendix.setDataLength(reply.getBodyLength());
appendix.setCompressed(reply.getHeaderFlag(SCMPHeaderAttributeKey.COMPRESSION));
appendix.setSessionId(this.sessionId);
appendix.setCacheId(reply.getCacheId());
appendix.setCached(reply.getHeaderFlag(SCMPHeaderAttributeKey.CACHED));
appendix.setCachePartNr(reply.getHeader(SCMPHeaderAttributeKey.CACHE_PARTN_NUMBER));
appendix.setMessageInfo(reply.getHeader(SCMPHeaderAttributeKey.MSG_INFO));
appendix.setAppErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.APP_ERROR_CODE));
appendix.setAppErrorText(reply.getHeader(SCMPHeaderAttributeKey.APP_ERROR_TEXT));
appendix.setCachingMethod(SC_CACHING_METHOD.APPEND);
managedMsg.addAppendix(appendix);
}
return managedMsg;
}