use of nl.nn.adapterframework.core.PipeLine in project iaf by ibissource.
the class MessageSendingPipe method sendMessage.
protected PipeRunResult sendMessage(Message input, PipeLineSession session, ISender sender, Map<String, Object> threadContext) throws SenderException, TimeoutException, IOException, InterruptedException {
long startTime = System.currentTimeMillis();
PipeRunResult sendResult = null;
String exitState = null;
try {
PipeLine pipeline = getPipeLine();
if (pipeline != null) {
Adapter adapter = pipeline.getAdapter();
if (adapter != null) {
if (getPresumedTimeOutInterval() >= 0 && !isConfigurationStubbed) {
long lastExitIsTimeoutDate = adapter.getLastExitIsTimeoutDate(getName());
if (lastExitIsTimeoutDate > 0) {
long duration = startTime - lastExitIsTimeoutDate;
if (duration < (1000L * getPresumedTimeOutInterval())) {
exitState = PRESUMED_TIMEOUT_FORWARD;
throw new TimeoutException(getLogPrefix(session) + exitState);
}
}
}
}
}
try {
if (sender instanceof IStreamingSender && canStreamToNextPipe() && getOutputValidator() == null && getOutputWrapper() == null && !isStreamResultToServlet()) {
sendResult = ((IStreamingSender) sender).sendMessage(input, session, getNextPipe());
} else {
// sendResult has a messageID for async senders, the result for sync senders
Message result = sender.sendMessage(input, session);
sendResult = new PipeRunResult(null, result);
}
} catch (SenderException se) {
exitState = PipeForward.EXCEPTION_FORWARD_NAME;
throw se;
} catch (TimeoutException toe) {
exitState = TIMEOUT_FORWARD;
throw toe;
}
if (Thread.currentThread().isInterrupted()) {
exitState = INTERRUPT_FORWARD;
throw new InterruptedException();
}
Message sendResultMessage = sendResult.getResult();
if (sendResultMessage.asObject() instanceof String) {
String result = (String) sendResultMessage.asObject();
if (StringUtils.isNotEmpty(getTimeOutOnResult()) && getTimeOutOnResult().equals(result)) {
exitState = TIMEOUT_FORWARD;
throw new TimeoutException(getLogPrefix(session) + "timeOutOnResult [" + getTimeOutOnResult() + "]");
}
if (StringUtils.isNotEmpty(getExceptionOnResult()) && getExceptionOnResult().equals(result)) {
exitState = PipeForward.EXCEPTION_FORWARD_NAME;
throw new SenderException(getLogPrefix(session) + "exceptionOnResult [" + getExceptionOnResult() + "]");
}
}
} finally {
if (exitState == null) {
exitState = PipeForward.SUCCESS_FORWARD_NAME;
}
PipeLine pipeline = getPipeLine();
if (pipeline != null) {
Adapter adapter = pipeline.getAdapter();
if (adapter != null) {
if (getPresumedTimeOutInterval() >= 0 && !ConfigurationUtils.isConfigurationStubbed(getConfigurationClassLoader())) {
if (!PRESUMED_TIMEOUT_FORWARD.equals(exitState)) {
adapter.setLastExitState(getName(), System.currentTimeMillis(), exitState);
}
}
String duration;
if (msgLogHumanReadable) {
duration = Misc.getAge(startTime);
} else {
duration = Misc.getDurationInMs(startTime);
}
if (msgLog.getLevel().isMoreSpecificThan(MSGLOG_LEVEL_TERSE)) {
msgLog.log(MSGLOG_LEVEL_TERSE, String.format("Sender [%s] class [%s] duration [%s] got exit-state [%s]", sender.getName(), ClassUtils.nameOf(sender), duration, exitState));
}
}
}
}
return sendResult;
}
use of nl.nn.adapterframework.core.PipeLine in project iaf by ibissource.
the class WsdlGeneratorTest method testInputValidatorWithSchemaAttribute.
@Test(expected = IllegalStateException.class)
public void testInputValidatorWithSchemaAttribute() throws Exception {
PipeLine pipeline = createPipeline();
XmlValidator inputValidator = new XmlValidator();
inputValidator.setSchema(validateResource("/OpenApi/simple.xsd"));
pipeline.setInputValidator(inputValidator);
WsdlGenerator generator = new WsdlGenerator(pipeline);
assertNotNull(generator);
}
use of nl.nn.adapterframework.core.PipeLine in project iaf by ibissource.
the class WsdlGeneratorTest method createPipeline.
private PipeLine createPipeline() throws Exception {
EchoPipe pipe = new EchoPipe();
pipe.registerForward(new PipeForward("success", null));
pipe.setName(pipe.getClass().getSimpleName().concat("4WsdlGeneratorTest"));
PipeLine pipeline = new PipeLine();
pipeline.addPipe(pipe);
PipeLineExit exit = new PipeLineExit();
exit.setPath("exit");
exit.setState(ExitState.SUCCESS);
pipeline.registerPipeLineExit(exit);
Adapter adapter = new Adapter();
adapter.setName(pipe.getClass().getSimpleName().concat("4WsdlGeneratorTest"));
adapter.setPipeLine(pipeline);
pipeline.setAdapter(adapter);
return pipeline;
}
use of nl.nn.adapterframework.core.PipeLine in project iaf by ibissource.
the class JobDef method cleanupDatabase.
private void cleanupDatabase(IbisManager ibisManager) {
Date date = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formattedDate = formatter.format(date);
List<String> jmsRealmNames = new ArrayList<String>();
for (Configuration configuration : ibisManager.getConfigurations()) {
List<JobDef> scheduledJobs = configuration.getScheduledJobs();
for (JobDef jobdef : configuration.getScheduledJobs()) {
if (jobdef.getLocker() != null) {
String jmsRealmName = jobdef.getLocker().getJmsRealName();
if (!jmsRealmNames.contains(jmsRealmName)) {
jmsRealmNames.add(jmsRealmName);
}
}
}
}
for (IAdapter adapter : ibisManager.getRegisteredAdapters()) {
if (adapter instanceof Adapter) {
PipeLine pipeLine = ((Adapter) adapter).getPipeLine();
if (pipeLine != null) {
for (IPipe pipe : pipeLine.getPipes()) {
if (pipe instanceof IExtendedPipe) {
IExtendedPipe extendedPipe = (IExtendedPipe) pipe;
if (extendedPipe.getLocker() != null) {
String jmsRealmName = extendedPipe.getLocker().getJmsRealName();
if (!jmsRealmNames.contains(jmsRealmName)) {
jmsRealmNames.add(jmsRealmName);
}
}
}
}
}
}
}
for (Iterator iter = jmsRealmNames.iterator(); iter.hasNext(); ) {
String jmsRealmName = (String) iter.next();
setJmsRealm(jmsRealmName);
DirectQuerySender qs;
qs = (DirectQuerySender) ibisManager.getIbisContext().createBeanAutowireByName(DirectQuerySender.class);
qs.setJmsRealm(jmsRealmName);
String deleteQuery;
if (qs.getDatabaseType() == DbmsSupportFactory.DBMS_MSSQLSERVER) {
deleteQuery = "DELETE FROM IBISLOCK WHERE EXPIRYDATE < CONVERT(datetime, '" + formattedDate + "', 120)";
} else {
deleteQuery = "DELETE FROM IBISLOCK WHERE EXPIRYDATE < TO_TIMESTAMP('" + formattedDate + "', 'YYYY-MM-DD HH24:MI:SS')";
}
setQuery(deleteQuery);
qs = null;
executeQueryJob(ibisManager);
}
List messageLogs = new ArrayList();
for (IAdapter iadapter : ibisManager.getRegisteredAdapters()) {
Adapter adapter = (Adapter) iadapter;
PipeLine pipeline = adapter.getPipeLine();
for (int i = 0; i < pipeline.getPipes().size(); i++) {
IPipe pipe = pipeline.getPipe(i);
if (pipe instanceof MessageSendingPipe) {
MessageSendingPipe msp = (MessageSendingPipe) pipe;
if (msp.getMessageLog() != null) {
ITransactionalStorage transactionStorage = msp.getMessageLog();
if (transactionStorage instanceof JdbcTransactionalStorage) {
JdbcTransactionalStorage messageLog = (JdbcTransactionalStorage) transactionStorage;
String jmsRealmName = messageLog.getJmsRealName();
String expiryDateField = messageLog.getExpiryDateField();
String tableName = messageLog.getTableName();
String keyField = messageLog.getKeyField();
String typeField = messageLog.getTypeField();
MessageLogObject mlo = new MessageLogObject(jmsRealmName, tableName, expiryDateField, keyField, typeField);
if (!messageLogs.contains(mlo)) {
messageLogs.add(mlo);
}
}
}
}
}
}
for (Iterator iter = messageLogs.iterator(); iter.hasNext(); ) {
MessageLogObject mlo = (MessageLogObject) iter.next();
setJmsRealm(mlo.getJmsRealmName());
DirectQuerySender qs;
qs = (DirectQuerySender) ibisManager.getIbisContext().createBeanAutowireByName(DirectQuerySender.class);
qs.setJmsRealm(mlo.getJmsRealmName());
String deleteQuery;
if (qs.getDatabaseType() == DbmsSupportFactory.DBMS_MSSQLSERVER) {
deleteQuery = "DELETE FROM " + mlo.getTableName() + " WHERE " + mlo.getKeyField() + " IN (SELECT " + mlo.getKeyField() + " FROM " + mlo.getTableName() + " WITH (rowlock,updlock,readpast) WHERE " + mlo.getTypeField() + " IN ('" + JdbcTransactionalStorage.TYPE_MESSAGELOG_PIPE + "','" + JdbcTransactionalStorage.TYPE_MESSAGELOG_RECEIVER + "') AND " + mlo.getExpiryDateField() + " < CONVERT(datetime, '" + formattedDate + "', 120))";
} else {
deleteQuery = "DELETE FROM " + mlo.getTableName() + " WHERE " + mlo.getTypeField() + " IN ('" + JdbcTransactionalStorage.TYPE_MESSAGELOG_PIPE + "','" + JdbcTransactionalStorage.TYPE_MESSAGELOG_RECEIVER + "') AND " + mlo.getExpiryDateField() + " < TO_TIMESTAMP('" + formattedDate + "', 'YYYY-MM-DD HH24:MI:SS')";
}
qs = null;
setQuery(deleteQuery);
setQueryTimeout(900);
executeQueryJob(ibisManager);
}
}
use of nl.nn.adapterframework.core.PipeLine in project iaf by ibissource.
the class ShowConfigurationStatusTest method testAllConfigs.
@Test
public void testAllConfigs() throws ConfigurationException, PipeRunException, DomBuilderException, SAXException, IOException, TransformerException {
ShowConfigurationStatus showConfigurationStatus = new ShowConfigurationStatus();
PipeLine pipeLine = new PipeLine();
Adapter adapter = (Adapter) ibisContext.getIbisManager().getRegisteredAdapter("WebControlShowConfigurationStatus");
pipeLine.setAdapter(adapter);
showConfigurationStatus.registerForward(createPipeSuccessForward());
showConfigurationStatus.configure(pipeLine);
session.put("configuration", "*ALL*");
MockHttpServletRequest request = new MockHttpServletRequest();
session.put(IPipeLineSession.HTTP_REQUEST_KEY, request);
PipeRunResult pipeRunResult = showConfigurationStatus.doPipe(null, session);
compareXML("webcontrol/allConfigs.xml", (String) pipeRunResult.getResult());
}
Aggregations