use of nl.nn.adapterframework.extensions.ifsa.IfsaException in project iaf by ibissource.
the class IfsaRequesterSender method getRawReplyMessage.
/**
* Retrieves a message with the specified correlationId from queue or other channel, but does no processing on it.
*/
private Message getRawReplyMessage(QueueSession session, IFSAQueue queue, TextMessage sentMessage) throws SenderException, TimeOutException {
String selector = null;
Message msg = null;
QueueReceiver replyReceiver = null;
try {
replyReceiver = getReplyReceiver(session, sentMessage);
selector = replyReceiver.getMessageSelector();
long timeout = getExpiry(queue);
log.debug(getLogPrefix() + "start waiting at most [" + timeout + "] ms for reply on message using selector [" + selector + "]");
msg = replyReceiver.receive(timeout);
if (msg == null) {
log.info(getLogPrefix() + "received null reply");
} else {
log.info(getLogPrefix() + "received reply");
}
} catch (Exception e) {
throw new SenderException(getLogPrefix() + "got exception retrieving reply", e);
} finally {
try {
closeReplyReceiver(replyReceiver);
} catch (IfsaException e) {
log.error(getLogPrefix() + "error closing replyreceiver", e);
}
}
if (msg == null) {
throw new TimeOutException(getLogPrefix() + " timed out waiting for reply using selector [" + selector + "]");
}
if (msg instanceof IFSATimeOutMessage) {
throw new TimeOutException(getLogPrefix() + "received IFSATimeOutMessage waiting for reply using selector [" + selector + "]");
}
return msg;
// try {
// TextMessage result = (TextMessage)msg;
// return result;
// } catch (Exception e) {
// throw new SenderException(getLogPrefix()+"reply received for message using selector ["+selector+"] cannot be cast to TextMessage ["+msg.getClass().getName()+"]",e);
// }
}
use of nl.nn.adapterframework.extensions.ifsa.IfsaException in project iaf by ibissource.
the class PullingIfsaProviderListener method openThread.
public Map openThread() throws ListenerException {
Map threadContext = new HashMap();
try {
if (!isSessionsArePooled()) {
QueueSession session = createSession();
threadContext.put(THREAD_CONTEXT_SESSION_KEY, session);
QueueReceiver receiver;
receiver = getServiceReceiver(session);
threadContext.put(THREAD_CONTEXT_RECEIVER_KEY, receiver);
}
return threadContext;
} catch (IfsaException e) {
throw new ListenerException(getLogPrefix() + "exception in openThread()", e);
}
}
use of nl.nn.adapterframework.extensions.ifsa.IfsaException in project iaf by ibissource.
the class PushingIfsaProviderListener method close.
public void close() throws ListenerException {
try {
jmsConnector.stop();
closeService();
} catch (IfsaException e) {
throw new ListenerException(getLogPrefix(), e);
}
}
use of nl.nn.adapterframework.extensions.ifsa.IfsaException in project iaf by ibissource.
the class PushingIfsaProviderListener method afterMessageProcessed.
public void afterMessageProcessed(PipeLineResult plr, Object rawMessage, Map threadContext) throws ListenerException {
QueueSession session = (QueueSession) threadContext.get(IListenerConnector.THREAD_CONTEXT_SESSION_KEY);
// on request-reply send the reply.
if (getMessageProtocolEnum().equals(IfsaMessageProtocolEnum.REQUEST_REPLY)) {
Message originalRawMessage;
if (rawMessage instanceof Message) {
originalRawMessage = (Message) rawMessage;
} else {
originalRawMessage = (Message) threadContext.get(THREAD_CONTEXT_ORIGINAL_RAW_MESSAGE_KEY);
}
if (originalRawMessage == null) {
String cid = (String) threadContext.get(IPipeLineSession.businessCorrelationIdKey);
log.warn(getLogPrefix() + "no original raw message found for correlationId [" + cid + "], cannot send result");
} else {
if (session == null) {
throw new ListenerException(getLogPrefix() + "no session found in context, cannot send result");
}
try {
String result = "<exception>no result</exception>";
if (plr != null && plr.getResult() != null) {
result = plr.getResult();
}
sendReply(session, originalRawMessage, result);
} catch (IfsaException e) {
try {
sendReply(session, originalRawMessage, "<exception>" + e.getMessage() + "</exception>");
} catch (IfsaException e2) {
log.warn(getLogPrefix() + "exception sending errormessage as reply", e2);
}
throw new ListenerException(getLogPrefix() + "Exception on sending result", e);
}
}
}
}
use of nl.nn.adapterframework.extensions.ifsa.IfsaException in project iaf by ibissource.
the class IfsaFacade method sendMessage.
/**
* Sends a message,and if transacted, the queueSession is committed.
* <p>This method is intended for <b>clients</b>, as <b>server</b>s
* will use the <code>sendReply</code>.
* @return the correlationID of the sent message
*/
public TextMessage sendMessage(QueueSession session, QueueSender sender, String message, Map udzMap, String bifName, byte[] btcData) throws IfsaException {
try {
if (!isRequestor()) {
throw new IfsaException(getLogPrefix() + "Provider cannot use sendMessage, should use sendReply");
}
IFSATextMessage msg = (IFSATextMessage) session.createTextMessage();
msg.setText(message);
if (udzMap != null && msg instanceof IFSAMessage) {
// Handle UDZs
log.debug(getLogPrefix() + "add UDZ map to IFSAMessage");
// process the udzMap
Map udzObject = (Map) ((IFSAMessage) msg).getOutgoingUDZObject();
udzObject.putAll(udzMap);
}
String replyToQueueName = "-";
// Client side
if (messageProtocol.equals(IfsaMessageProtocolEnum.REQUEST_REPLY)) {
// set reply-to address
Queue replyTo = getMessagingSource().getClientReplyQueue(session);
msg.setJMSReplyTo(replyTo);
replyToQueueName = replyTo.getQueueName();
}
if (messageProtocol.equals(IfsaMessageProtocolEnum.FIRE_AND_FORGET)) {
// not applicable
}
if (StringUtils.isNotEmpty(bifName)) {
msg.setBifName(bifName);
}
if (btcData != null && btcData.length > 0) {
msg.setBtcData(btcData);
}
if (log.isDebugEnabled()) {
log.debug(getLogPrefix() + " messageProtocol [" + messageProtocol + "] replyToQueueName [" + replyToQueueName + "] sending message [" + message + "]");
} else {
if (log.isInfoEnabled()) {
log.info(getLogPrefix() + " messageProtocol [" + messageProtocol + "] replyToQueueName [" + replyToQueueName + "] sending message");
}
}
// send the message
sender.send(msg);
// perform commit
if (isJmsTransacted() && !(messagingSource.isXaEnabledForSure() && JtaUtil.inTransaction())) {
session.commit();
log.debug(getLogPrefix() + "committing (send) transaction");
}
return msg;
} catch (Exception e) {
throw new IfsaException(e);
}
}
Aggregations