use of nl.nn.adapterframework.core.TimeoutException in project iaf by ibissource.
the class FileSender method sendMessage.
/**
* Send the message to the specified file. After writing the message to
* file, this method will check if the file is deleted by another party
* (detect reading of the file).
*
* @param message the message to write to file
*/
public void sendMessage(String message) throws TimeoutException, SenderException {
if (runAnt) {
runAntScript();
} else {
if (deletePath) {
File file = new File(filename);
if (file.exists()) {
recursiveDelete(filename);
}
} else {
if (createPath) {
File file = new File(filename);
if (file.exists()) {
throw new SenderException("Path '" + filename + "' already exists.");
}
file.mkdirs();
} else {
File file = new File(filename);
if (!overwrite && file.exists()) {
throw new SenderException("File '" + filename + "' already exists.");
}
String pathname = file.getParent();
File path = new File(pathname);
if (!path.exists()) {
path.mkdirs();
}
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(message.getBytes(encoding));
fileOutputStream.close();
} catch (Exception e) {
throw new SenderException("Exception writing file '" + filename + "': " + e.getMessage(), e);
}
long startTime = System.currentTimeMillis();
while (checkDelete && file.exists() && System.currentTimeMillis() < startTime + timeOut) {
try {
Thread.sleep(interval);
} catch (InterruptedException e) {
throw new SenderException("Exception waiting for deletion of file '" + filename + "': " + e.getMessage(), e);
}
}
if (checkDelete && file.exists()) {
throw new TimeoutException("Time out waiting for deletion of file '" + filename + "'.");
}
}
}
}
}
use of nl.nn.adapterframework.core.TimeoutException in project iaf by ibissource.
the class ListenerMessageHandler method processRequest.
@Override
public Message processRequest(IListener<M> origin, String correlationId, M rawMessage, Message message, Map<String, Object> context) throws ListenerException {
try {
ListenerMessage requestMessage = new ListenerMessage(correlationId, message.asString(), context);
requestMessages.add(requestMessage);
ListenerMessage responseMessage = getResponseMessage(defaultTimeout);
return new Message(responseMessage.getMessage());
} catch (IOException e) {
throw new ListenerException("cannot convert message to string", e);
} catch (TimeoutException e) {
throw new ListenerException("error processing request", e);
}
}
use of nl.nn.adapterframework.core.TimeoutException in project iaf by ibissource.
the class SenderThread method run.
@Override
public void run() {
try {
if (session == null) {
session = new PipeLineSession();
}
session.put(PipeLineSession.businessCorrelationIdKey, TestTool.TESTTOOL_CORRELATIONID);
response = sender.sendMessage(new Message(request), session).asString();
} catch (SenderException e) {
if (convertExceptionToMessage) {
response = Util.throwableToXml(e);
} else {
log.error("SenderException for ISender '" + name + "'", e);
senderException = e;
}
} catch (IOException e) {
if (convertExceptionToMessage) {
response = Util.throwableToXml(e);
} else {
log.error("IOException for ISender '" + name + "'", e);
ioException = e;
}
} catch (TimeoutException e) {
if (convertExceptionToMessage) {
response = Util.throwableToXml(e);
} else {
log.error("timeOutException for ISender '" + name + "'", e);
timeOutException = e;
}
}
}
Aggregations