use of nl.nn.adapterframework.core.TimeOutException in project iaf by ibissource.
the class ReloadSender method sendMessage.
@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
String configName = null;
String activeVersion = null;
boolean forceReload = getForceReload();
ParameterValueList pvl = null;
try {
if (paramList != null) {
pvl = paramList.getValues(message, session);
if (pvl.getParameterValue("name") != null)
configName = pvl.getParameterValue("name").asStringValue();
if (pvl.getParameterValue("forceReload") != null)
forceReload = pvl.getParameterValue("forceReload").asBooleanValue(false);
}
} catch (ParameterException e) {
throw new SenderException(getLogPrefix() + "Sender [" + getName() + "] caught exception evaluating parameters", e);
}
try {
if (configName == null)
configName = XmlUtils.evaluateXPathNodeSetFirstElement(message.asString(), "row/field[@name='NAME']");
} catch (Exception e) {
throw new SenderException(getLogPrefix() + "error evaluating Xpath expression configName", e);
}
try {
if (!forceReload) {
activeVersion = XmlUtils.evaluateXPathNodeSetFirstElement(message.asString(), "row/field[@name='VERSION']");
}
} catch (Exception e) {
throw new SenderException(getLogPrefix() + "error evaluating Xpath expression activeVersion", e);
}
Configuration configuration = ibisManager.getConfiguration(configName);
if (configuration != null) {
String latestVersion = configuration.getVersion();
if (forceReload || (latestVersion != null && !activeVersion.equals(latestVersion))) {
IbisContext ibisContext = ibisManager.getIbisContext();
ibisContext.reload(configName);
return new Message("Reload " + configName + " succeeded");
}
return new Message("Reload " + configName + " skipped");
}
log.warn("Configuration [" + configName + "] not loaded yet");
return new Message("Reload " + configName + " skipped");
}
use of nl.nn.adapterframework.core.TimeOutException in project iaf by ibissource.
the class ForEachChildElementPipeTest method testTimeout.
@Test
public void testTimeout() throws Exception {
Exception targetException = new TimeoutException("FakeTimeout");
pipe.setSender(getElementRenderer(targetException));
configurePipe();
pipe.start();
try {
doPipe(pipe, messageError, session);
fail("Expected exception to be thrown");
} catch (Exception e) {
assertThat(e.getMessage(), StringContains.containsString("FakeTimeout"));
assertCauseChainEndsAtOriginalException(targetException, e);
}
}
use of nl.nn.adapterframework.core.TimeOutException in project iaf by ibissource.
the class ForEachChildElementPipeTest method testTimeoutXpath.
@Test
public void testTimeoutXpath() throws Exception {
Exception targetException = new TimeoutException("FakeTimeout");
pipe.setSender(getElementRenderer(targetException));
pipe.setElementXPathExpression("/root/sub");
configurePipe();
pipe.start();
try {
doPipe(pipe, messageError, session);
fail("Expected exception to be thrown");
} catch (Exception e) {
assertThat(e.getMessage(), StringContains.containsString("FakeTimeout"));
assertCauseChainEndsAtOriginalException(targetException, e);
}
}
use of nl.nn.adapterframework.core.TimeOutException in project iaf by ibissource.
the class TestTool method executeFixedQuerySenderRead.
private static int executeFixedQuerySenderRead(String step, String stepDisplayName, Properties properties, Map<String, Map<String, Object>> queues, Map<String, Object> writers, String queueName, String fileName, String fileContent) {
int result = RESULT_ERROR;
Map querySendersInfo = (Map) queues.get(queueName);
Integer waitBeforeRead = (Integer) querySendersInfo.get("readQueryWaitBeforeRead");
if (waitBeforeRead != null) {
try {
Thread.sleep(waitBeforeRead.intValue());
} catch (InterruptedException e) {
}
}
boolean newRecordFound = true;
FixedQuerySender prePostFixedQuerySender = (FixedQuerySender) querySendersInfo.get("prePostQueryFixedQuerySender");
if (prePostFixedQuerySender != null) {
try {
String preResult = (String) querySendersInfo.get("prePostQueryResult");
debugPipelineMessage(stepDisplayName, "Pre result '" + queueName + "':", preResult, writers);
PipeLineSession session = new PipeLineSession();
session.put(PipeLineSession.businessCorrelationIdKey, TestTool.TESTTOOL_CORRELATIONID);
String postResult = prePostFixedQuerySender.sendMessage(TESTTOOL_DUMMY_MESSAGE, session).asString();
debugPipelineMessage(stepDisplayName, "Post result '" + queueName + "':", postResult, writers);
if (preResult.equals(postResult)) {
newRecordFound = false;
}
/* Fill the preResult with postResult, so closeQueues is able to determine if there
* are remaining messages left.
*/
querySendersInfo.put("prePostQueryResult", postResult);
} catch (TimeoutException e) {
errorMessage("Time out on execute query for '" + queueName + "': " + e.getMessage(), e, writers);
} catch (IOException | SenderException e) {
errorMessage("Could not execute query for '" + queueName + "': " + e.getMessage(), e, writers);
}
}
String message = null;
if (newRecordFound) {
FixedQuerySender readQueryFixedQuerySender = (FixedQuerySender) querySendersInfo.get("readQueryQueryFixedQuerySender");
try {
PipeLineSession session = new PipeLineSession();
session.put(PipeLineSession.businessCorrelationIdKey, TestTool.TESTTOOL_CORRELATIONID);
message = readQueryFixedQuerySender.sendMessage(TESTTOOL_DUMMY_MESSAGE, session).asString();
} catch (TimeoutException e) {
errorMessage("Time out on execute query for '" + queueName + "': " + e.getMessage(), e, writers);
} catch (IOException | SenderException e) {
errorMessage("Could not execute query for '" + queueName + "': " + e.getMessage(), e, writers);
}
}
if (message == null) {
if ("".equals(fileName)) {
result = RESULT_OK;
} else {
errorMessage("Could not read jdbc message (null returned) or no new message found (pre result equals post result)", writers);
}
} else {
if ("".equals(fileName)) {
debugPipelineMessage(stepDisplayName, "Unexpected message read from '" + queueName + "':", message, writers);
} else {
result = compareResult(step, stepDisplayName, fileName, fileContent, message, properties, writers, queueName);
}
}
return result;
}
use of nl.nn.adapterframework.core.TimeOutException in project iaf by ibissource.
the class TestTool method executeJmsSenderWrite.
private static int executeJmsSenderWrite(String stepDisplayName, Map<String, Map<String, Object>> queues, Map<String, Object> writers, String queueName, String fileContent) {
int result = RESULT_ERROR;
Map<?, ?> jmsSenderInfo = (Map<?, ?>) queues.get(queueName);
JmsSender jmsSender = (JmsSender) jmsSenderInfo.get("jmsSender");
try {
String correlationId = null;
String useCorrelationIdFrom = (String) jmsSenderInfo.get("useCorrelationIdFrom");
if (useCorrelationIdFrom != null) {
Map<?, ?> listenerInfo = (Map<?, ?>) queues.get(useCorrelationIdFrom);
if (listenerInfo == null) {
errorMessage("Could not find listener '" + useCorrelationIdFrom + "' to use correlation id from", writers);
} else {
correlationId = (String) listenerInfo.get("correlationId");
if (correlationId == null) {
errorMessage("Could not find correlation id from listener '" + useCorrelationIdFrom + "'", writers);
}
}
}
if (correlationId == null) {
correlationId = (String) jmsSenderInfo.get("jmsCorrelationId");
}
if (correlationId == null) {
correlationId = TESTTOOL_CORRELATIONID;
}
jmsSender.sendMessage(new nl.nn.adapterframework.stream.Message(fileContent), null);
debugPipelineMessage(stepDisplayName, "Successfully written to '" + queueName + "':", fileContent, writers);
result = RESULT_OK;
} catch (TimeoutException e) {
errorMessage("Time out sending jms message to '" + queueName + "': " + e.getMessage(), e, writers);
} catch (SenderException e) {
errorMessage("Could not send jms message to '" + queueName + "': " + e.getMessage(), e, writers);
}
return result;
}
Aggregations