use of nl.nn.adapterframework.core.TimeoutException in project iaf by ibissource.
the class CmisHttpSender method invoke.
public Response invoke(HttpMethod method, String url, Map<String, String> headers, Output writer, BindingSession session) throws SenderException, TimeoutException {
// Prepare the message. We will overwrite things later...
int responseCode = -1;
PipeLineSession pls = new PipeLineSession();
pls.put("writer", writer);
pls.put("url", url);
pls.put("method", method);
pls.put("headers", headers);
try {
// Message is unused, we use 'Output writer' instead
sendMessage(new Message(""), pls);
return (Response) pls.get("response");
} catch (Exception e) {
throw new CmisConnectionException(getUrl(), responseCode, e);
}
}
use of nl.nn.adapterframework.core.TimeoutException in project iaf by ibissource.
the class BisJmsSender method sendMessage.
@Override
public Message sendMessage(Message input, PipeLineSession session) throws SenderException, TimeoutException {
String messageHeader;
try {
messageHeader = bisUtils.prepareMessageHeader(null, isMessageHeaderInSoapBody(), (String) session.get(getConversationIdSessionKey()), (String) session.get(getExternalRefToMessageIdSessionKey()));
} catch (Exception e) {
throw new SenderException(e);
}
String replyMessage;
try {
Message payload = bisUtils.prepareReply(input, isMessageHeaderInSoapBody() ? messageHeader : null, null, false);
if (StringUtils.isNotEmpty(getRequestNamespace())) {
payload = new Message(XmlUtils.addRootNamespace(payload.asString(), getRequestNamespace()));
}
replyMessage = super.sendMessage(payload, session, isMessageHeaderInSoapBody() ? null : messageHeader).asString();
} catch (Exception e) {
throw new SenderException(e);
}
if (isSynchronous()) {
String bisError;
String bisErrorList;
try {
bisError = bisErrorTp.transform(replyMessage, null, true);
bisErrorList = bisErrorListTp.transform(replyMessage, null, true);
} catch (Exception e) {
throw new SenderException(e);
}
if (Boolean.valueOf(bisError).booleanValue()) {
log.debug("put in session [" + getErrorListSessionKey() + "] [" + bisErrorList + "]");
session.put(getErrorListSessionKey(), bisErrorList);
throw new SenderException("bisErrorXPath [" + (isResultInPayload() ? bisUtils.getBisErrorXPath() : bisUtils.getOldBisErrorXPath()) + "] returns true");
}
try {
replyMessage = responseTp.transform(replyMessage, null, true);
if (isRemoveResponseNamespaces()) {
replyMessage = XmlUtils.removeNamespaces(replyMessage);
}
if (isResultInPayload()) {
Element soapBodyElement = XmlUtils.buildElement(replyMessage, true);
Element resultElement = XmlUtils.getFirstChildTag(soapBodyElement, "Result");
if (resultElement != null) {
soapBodyElement.removeChild(resultElement);
}
replyMessage = XmlUtils.nodeToString(soapBodyElement);
}
return new Message(replyMessage);
} catch (Exception e) {
throw new SenderException(e);
}
} else {
return new Message(replyMessage);
}
}
use of nl.nn.adapterframework.core.TimeoutException in project iaf by ibissource.
the class XmlFileElementIteratorPipe method iterateOverInput.
@Override
protected StopReason iterateOverInput(Message input, PipeLineSession session, Map<String, Object> threadContext, ItemCallback callback) throws SenderException, TimeoutException {
InputStream xmlInput;
try {
xmlInput = new FileInputStream(input.asString());
} catch (IOException e) {
throw new SenderException("could not find file [" + input + "]", e);
}
ItemCallbackCallingHandler handler = new ItemCallbackCallingHandler(callback);
log.debug("obtaining list of elements [" + getElementName() + "] using sax parser");
try {
SAXParserFactory parserFactory = XmlUtils.getSAXParserFactory();
parserFactory.setNamespaceAware(true);
SAXParser saxParser = parserFactory.newSAXParser();
saxParser.parse(xmlInput, handler);
} catch (Exception e) {
if (handler.getTimeOutException() != null) {
throw handler.getTimeOutException();
}
if (!handler.isStopRequested()) {
throw new SenderException("Could not extract list of elements [" + getElementName() + "] using sax parser", e);
}
try {
handler.endDocument();
} catch (SAXException e1) {
throw new SenderException("could not endDocument after stop was requested", e1);
}
}
return handler.stopReason;
}
use of nl.nn.adapterframework.core.TimeoutException in project iaf by ibissource.
the class IteratingPipe method sendMessage.
@Override
protected PipeRunResult sendMessage(Message input, PipeLineSession session, ISender sender, Map<String, Object> threadContext) throws SenderException, TimeoutException, IOException {
// sendResult has a messageID for async senders, the result for sync senders
StopReason stopReason = null;
try (MessageOutputStream target = getTargetStream(session)) {
try (Writer resultWriter = target.asWriter()) {
ItemCallback callback = createItemCallBack(session, sender, resultWriter);
stopReason = iterateOverInput(input, session, threadContext, callback);
}
PipeRunResult prr = target.getPipeRunResult();
if (stopReason != null) {
PipeForward forward = getForwards().get(stopReason.getForwardName());
if (forward != null) {
prr.setPipeForward(forward);
}
}
return prr;
} catch (SenderException | TimeoutException | IOException e) {
throw e;
} catch (Exception e) {
throw new SenderException(getLogPrefix(session) + "Exception on transforming input", e);
}
}
use of nl.nn.adapterframework.core.TimeoutException in project iaf by ibissource.
the class XmlValidatorSender method sendMessage.
@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
String fullReasons = "tja";
try {
String resultEvent = validate(message, session, getLogPrefix(), null, null);
if (AbstractXmlValidator.XML_VALIDATOR_VALID_MONITOR_EVENT.equals(resultEvent)) {
return message;
}
// TODO: find real fullReasons
fullReasons = resultEvent;
if (isThrowException()) {
throw new SenderException(fullReasons);
}
log.warn(fullReasons);
return message;
} catch (Exception e) {
if (isThrowException()) {
throw new SenderException(e);
}
log.warn(fullReasons, e);
return message;
}
}
Aggregations