use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class SapListener method open.
public void open() throws ListenerException {
try {
openFacade();
log.debug(getLogPrefix() + "register ServerDataProvider");
Environment.registerServerDataProvider(this);
serverDataEventListener.updated(getName());
log.debug(getLogPrefix() + "start server");
JCoIDocServer server = JCoIDoc.getServer(getName());
server.setCallHandlerFactory(functionHandlerFactory);
server.setIDocHandlerFactory(this);
server.setTIDHandler(this);
server.addServerErrorListener(this);
server.addServerExceptionListener(this);
server.start();
} 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 {
log.debug(getLogPrefix() + "stop server");
JCoServer server = JCoServerFactory.getServer(getName());
server.stop();
log.debug(getLogPrefix() + "unregister ServerDataProvider");
// Delete doesn't work after stopping the server, when calling
// delete first the stop method will fail.
// serverDataEventListener.deleted(getName());
} catch (Exception e) {
throw new ListenerException(getLogPrefix() + "could not stop", e);
} finally {
try {
Environment.unregisterServerDataProvider(this);
} catch (Exception e) {
throw new ListenerException(getLogPrefix() + "could not unregister", e);
} finally {
closeFacade();
}
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class SapListener method afterMessageProcessed.
public void afterMessageProcessed(PipeLineResult processResult, Object rawMessage, Map threadContext) throws ListenerException {
try {
log.debug("SapListener.afterMessageProcessed");
message2FunctionResult((JCO.Function) rawMessage, processResult.getResult());
} catch (SapException e) {
throw new ListenerException(e);
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class IbisLocalSender method sendMessage.
public String sendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException, TimeOutException {
String result = null;
HashMap context = null;
if (paramList != null) {
try {
context = (HashMap) prc.getValueMap(paramList);
} catch (ParameterException e) {
throw new SenderException(getLogPrefix() + "exception evaluating parameters", e);
}
} else {
if (StringUtils.isNotEmpty(getReturnedSessionKeys())) {
context = new HashMap();
}
}
if (StringUtils.isNotEmpty(getServiceName())) {
try {
if (isIsolated()) {
if (isSynchronous()) {
log.debug(getLogPrefix() + "calling service [" + getServiceName() + "] in separate Thread");
result = isolatedServiceCaller.callServiceIsolated(getServiceName(), correlationID, message, context, false);
} else {
log.debug(getLogPrefix() + "calling service [" + getServiceName() + "] in asynchronously");
isolatedServiceCaller.callServiceAsynchronous(getServiceName(), correlationID, message, context, false);
result = message;
}
} else {
log.debug(getLogPrefix() + "calling service [" + getServiceName() + "] in same Thread");
result = ServiceDispatcher.getInstance().dispatchRequest(getServiceName(), correlationID, message, context);
}
} catch (ListenerException e) {
if (ExceptionUtils.getRootCause(e) instanceof TimeOutException) {
throw new TimeOutException(getLogPrefix() + "timeout calling service [" + getServiceName() + "]", e);
} else {
throw new SenderException(getLogPrefix() + "exception calling service [" + getServiceName() + "]", e);
}
} finally {
if (log.isDebugEnabled() && StringUtils.isNotEmpty(getReturnedSessionKeys())) {
log.debug("returning values of session keys [" + getReturnedSessionKeys() + "]");
}
if (prc != null) {
Misc.copyContext(getReturnedSessionKeys(), context, prc.getSession());
}
}
} else {
String javaListener;
if (StringUtils.isNotEmpty(getJavaListenerSessionKey())) {
javaListener = (String) prc.getSession().get(getJavaListenerSessionKey());
} else {
javaListener = getJavaListener();
}
try {
JavaListener listener = JavaListener.getListener(javaListener);
if (listener == null) {
String msg = "could not find JavaListener [" + javaListener + "]";
if (isThrowJavaListenerNotFoundException()) {
throw new SenderException(msg);
} else {
log.info(getLogPrefix() + msg);
return "<error>" + msg + "</error>";
}
}
if (isIsolated()) {
if (isSynchronous()) {
log.debug(getLogPrefix() + "calling JavaListener [" + javaListener + "] in separate Thread");
result = isolatedServiceCaller.callServiceIsolated(javaListener, correlationID, message, context, true);
} else {
log.debug(getLogPrefix() + "calling JavaListener [" + javaListener + "] in asynchronously");
isolatedServiceCaller.callServiceAsynchronous(javaListener, correlationID, message, context, true);
result = message;
}
} else {
log.debug(getLogPrefix() + "calling JavaListener [" + javaListener + "] in same Thread");
result = listener.processRequest(correlationID, message, context);
}
} catch (ListenerException e) {
if (ExceptionUtils.getRootCause(e) instanceof TimeOutException) {
throw new TimeOutException(getLogPrefix() + "timeout calling JavaListener [" + javaListener + "]", e);
} else {
throw new SenderException(getLogPrefix() + "exception calling JavaListener [" + javaListener + "]", e);
}
} finally {
if (log.isDebugEnabled() && StringUtils.isNotEmpty(getReturnedSessionKeys())) {
log.debug("returning values of session keys [" + getReturnedSessionKeys() + "]");
}
if (prc != null) {
Misc.copyContext(getReturnedSessionKeys(), context, prc.getSession());
}
}
}
return result;
}
Aggregations