use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class JavaListener method processRequest.
@Override
public String processRequest(String correlationId, String message, HashMap context) throws ListenerException {
if (!isOpen()) {
throw new ListenerException("JavaListener [" + getName() + "] is not opened");
}
if (log.isDebugEnabled()) {
log.debug("JavaListener [" + getName() + "] processing correlationId [" + correlationId + "]");
}
if (context != null) {
Object object = context.get("httpRequest");
if (object != null) {
if (object instanceof HttpServletRequest) {
ISecurityHandler securityHandler = new HttpSecurityHandler((HttpServletRequest) object);
context.put(IPipeLineSession.securityHandlerKey, securityHandler);
} else {
log.warn("No securityHandler added for httpRequest [" + object.getClass() + "]");
}
}
}
if (throwException) {
return handler.processRequest(this, correlationId, message, context);
} else {
try {
return handler.processRequest(this, correlationId, message, context);
} catch (ListenerException e) {
return handler.formatException(null, correlationId, message, e);
}
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class TestTool method jmsCleanUp.
public static boolean jmsCleanUp(String queueName, PullingJmsListener pullingJmsListener, Map writers) {
boolean remainingMessagesFound = false;
debugMessage("Check for remaining messages on '" + queueName + "'", writers);
long oldTimeOut = pullingJmsListener.getTimeOut();
pullingJmsListener.setTimeOut(10);
boolean empty = false;
while (!empty) {
Object rawMessage = null;
String message = null;
Map threadContext = null;
try {
threadContext = pullingJmsListener.openThread();
rawMessage = pullingJmsListener.getRawMessage(threadContext);
if (rawMessage != null) {
message = pullingJmsListener.getStringFromRawMessage(rawMessage, threadContext);
remainingMessagesFound = true;
if (message == null) {
errorMessage("Could not translate raw message from jms queue '" + queueName + "'", writers);
} else {
wrongPipelineMessage("Found remaining message on '" + queueName + "'", message, writers);
}
}
} catch (ListenerException e) {
errorMessage("ListenerException on jms clean up '" + queueName + "': " + e.getMessage(), e, writers);
} finally {
if (threadContext != null) {
try {
pullingJmsListener.closeThread(threadContext);
} catch (ListenerException e) {
errorMessage("Could not close thread on jms listener '" + queueName + "': " + e.getMessage(), e, writers);
}
}
}
if (rawMessage == null) {
empty = true;
}
}
pullingJmsListener.setTimeOut((int) oldTimeOut);
return remainingMessagesFound;
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class SapListener method open.
public void open() throws ListenerException {
try {
openFacade();
sapServer = new SapServer(getSapSystem(), getProgid(), this);
sapServer.start();
if (log.isDebugEnabled()) {
String[][] pi = sapServer.getPropertyInfo();
log.debug(getLogPrefix() + "properties:");
for (int i = 0; i < pi.length; i++) {
log.debug(getLogPrefix() + "property [" + pi[i][0] + "] (" + pi[i][1] + ") value (" + sapServer.getProperty(pi[i][0]) + ")");
}
}
} catch (Exception e) {
try {
close();
} catch (Exception e2) {
log.warn("exception closing SapListener after exception opening listener", e2);
}
throw new ListenerException(getLogPrefix() + "could not start", e);
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class SapListener method close.
public void close() throws ListenerException {
try {
if (sapServer != null) {
sapServer.stop();
sapServer = null;
}
} catch (Exception e) {
throw new ListenerException(getLogPrefix() + "could not stop", e);
} finally {
closeFacade();
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class PullingJmsListener method closeThread.
public void closeThread(Map threadContext) throws ListenerException {
try {
if (!isSessionsArePooled()) {
MessageConsumer mc = (MessageConsumer) threadContext.remove(THREAD_CONTEXT_MESSAGECONSUMER_KEY);
releaseReceiver(mc, null);
Session session = (Session) threadContext.remove(THREAD_CONTEXT_SESSION_KEY);
closeSession(session);
}
} catch (Exception e) {
throw new ListenerException("exception in [" + getName() + "]", e);
}
}
Aggregations