use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class ReceiverBase method moveInProcessToError.
private void moveInProcessToError(String originalMessageId, String correlationId, String message, Date receivedDate, String comments, Object rawMessage, TransactionDefinition txDef) {
cachePoisonMessageId(originalMessageId);
ISender errorSender = getErrorSender();
ITransactionalStorage errorStorage = getErrorStorage();
if (errorSender == null && errorStorage == null) {
log.debug(getLogPrefix() + "has no errorSender or errorStorage, will not move message with id [" + originalMessageId + "] correlationId [" + correlationId + "] to errorSender/errorStorage");
return;
}
throwEvent(RCV_MESSAGE_TO_ERRORSTORE_EVENT);
log.debug(getLogPrefix() + "moves message with id [" + originalMessageId + "] correlationId [" + correlationId + "] to errorSender/errorStorage");
TransactionStatus txStatus = null;
try {
txStatus = txManager.getTransaction(txDef);
} catch (Exception e) {
log.error(getLogPrefix() + "Exception preparing to move input message with id [" + originalMessageId + "] to error sender", e);
// no use trying again to send message on errorSender, will cause same exception!
return;
}
try {
if (errorSender != null) {
errorSender.sendMessage(correlationId, message);
}
Serializable sobj;
if (rawMessage instanceof Serializable) {
sobj = (Serializable) rawMessage;
} else {
try {
sobj = new MessageWrapper(rawMessage, getListener());
} catch (ListenerException e) {
log.error(getLogPrefix() + "could not wrap non serializable message for messageId [" + originalMessageId + "]", e);
sobj = message;
}
}
if (hideRegex != null) {
if (getHideMethod().equalsIgnoreCase("FIRSTHALF")) {
message = Misc.hideFirstHalf(message, hideRegex);
} else {
message = Misc.hideAll(message, hideRegex);
}
sobj = message;
}
if (errorStorage != null) {
errorStorage.storeMessage(originalMessageId, correlationId, receivedDate, comments, null, sobj);
}
txManager.commit(txStatus);
} catch (Exception e) {
log.error(getLogPrefix() + "Exception moving message with id [" + originalMessageId + "] correlationId [" + correlationId + "] to error sender, original message: [" + message + "]", e);
try {
if (!txStatus.isCompleted()) {
txManager.rollback(txStatus);
}
} catch (Exception rbe) {
log.error(getLogPrefix() + "Exception while rolling back transaction for message with id [" + originalMessageId + "] correlationId [" + correlationId + "], original message: [" + message + "]", rbe);
}
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class ReceiverBase method processRequest.
public String processRequest(IListener origin, String correlationId, String message, Map context, long waitingTime) throws ListenerException {
if (getRunState() != RunStateEnum.STARTED) {
throw new ListenerException(getLogPrefix() + "is not started");
}
Date tsReceived = null;
Date tsSent = null;
if (context != null) {
tsReceived = (Date) context.get(IPipeLineSession.tsReceivedKey);
tsSent = (Date) context.get(IPipeLineSession.tsSentKey);
} else {
context = new HashMap();
}
PipeLineSessionBase.setListenerParameters(context, null, correlationId, tsReceived, tsSent);
return processMessageInAdapter(origin, message, message, null, correlationId, context, waitingTime, false);
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class DirectoryListener method getIdFromRawMessage.
/**
* Returns the name of the file in process (the {@link #archiveFile(IPipeLineSession session, File file) archived} file) concatenated with the
* record number. As the {@link #archiveFile(IPipeLineSession session, File file) archivedFile} method always renames to a
* unique file, the combination of this filename and the recordnumber is unique, enabling tracing in case of errors
* in the processing of the file.
* Override this method for your specific needs!
*/
public String getIdFromRawMessage(Object rawMessage, Map threadContext) throws ListenerException {
if (getFileList() == null) {
String filename = rawMessage.toString();
String correlationId = filename;
if (isFileTimeSensitive()) {
try {
File f = new File(filename);
correlationId += "-" + DateUtils.format(f.lastModified());
} catch (Exception e) {
throw new ListenerException("Could not get filetime from filename [" + filename + "]", e);
}
}
PipeLineSessionBase.setListenerParameters(threadContext, correlationId, correlationId, null, null);
return correlationId;
} else {
return null;
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class ExchangeMailListener method afterMessageProcessed.
public void afterMessageProcessed(PipeLineResult processResult, Object rawMessage, Map context) throws ListenerException {
Item item = (Item) rawMessage;
try {
if (folderOut != null) {
item.move(folderOut.getId());
log.debug("moved item [" + item.getId() + "] from folder [" + folderIn.getDisplayName() + "] to folder [" + folderOut.getDisplayName() + "]");
} else {
item.delete(DeleteMode.MoveToDeletedItems);
log.debug("deleted item [" + item.getId() + "] from folder [" + folderIn.getDisplayName() + "]");
}
} catch (Exception e) {
throw new ListenerException(e);
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class JavaListener method open.
@Override
public synchronized void open() throws ListenerException {
try {
// add myself to local list so that IbisLocalSenders can find me
registerListener();
// (performed only if serviceName is not empty
if (StringUtils.isNotEmpty(getServiceName())) {
DispatcherManagerFactory.getDispatcherManager().register(getServiceName(), this);
}
opened = true;
} catch (Exception e) {
throw new ListenerException("error occured while starting listener [" + getName() + "]", e);
}
}
Aggregations