use of nl.nn.adapterframework.extensions.ifsa.IfsaException in project iaf by ibissource.
the class MessagingSource method deleteDynamicQueue.
private void deleteDynamicQueue(Queue queue) throws IfsaException {
if (queue != null) {
try {
if (!(queue instanceof TemporaryQueue)) {
throw new IfsaException("Queue [" + queue.getQueueName() + "] is not a TemporaryQueue");
}
TemporaryQueue tqueue = (TemporaryQueue) queue;
tqueue.delete();
} catch (JMSException e) {
throw new IfsaException("cannot delete temporary queue", e);
}
}
}
use of nl.nn.adapterframework.extensions.ifsa.IfsaException in project iaf by ibissource.
the class IfsaRequesterSender method sendMessage.
/**
* Execute a request to the IFSA service.
* @return in Request/Reply, the retrieved message or TIMEOUT, otherwise null
*/
public String sendMessage(String dummyCorrelationId, String message, Map params, String bifName, byte[] btcData) throws SenderException, TimeOutException {
String result = null;
QueueSession session = null;
QueueSender sender = null;
Map udzMap = null;
try {
log.debug(getLogPrefix() + "creating session and sender");
session = createSession();
IFSAQueue queue;
if (params != null && params.size() > 0) {
// Use first param as serviceId
String serviceId = (String) params.get("serviceId");
if (serviceId == null) {
serviceId = getServiceId();
}
String occurrence = (String) params.get("occurrence");
if (occurrence != null) {
int i = serviceId.indexOf('/', serviceId.indexOf('/', serviceId.indexOf('/', serviceId.indexOf('/') + 1) + 1) + 1);
int j = serviceId.indexOf('/', i + 1);
serviceId = serviceId.substring(0, i + 1) + occurrence + serviceId.substring(j);
}
queue = getMessagingSource().lookupService(getMessagingSource().polishServiceId(serviceId));
if (queue == null) {
throw new SenderException(getLogPrefix() + "got null as queue for serviceId [" + serviceId + "]");
}
if (log.isDebugEnabled()) {
log.info(getLogPrefix() + "got Queue to send messages on [" + queue.getQueueName() + "]");
}
// Use remaining params as outgoing UDZs
udzMap = new HashMap();
udzMap.putAll(params);
udzMap.remove("serviceId");
udzMap.remove("occurrence");
} else {
queue = getServiceQueue();
}
sender = createSender(session, queue);
log.debug(getLogPrefix() + "sending message with bifName [" + bifName + "]");
TextMessage sentMessage = sendMessage(session, sender, message, udzMap, bifName, btcData);
log.debug(getLogPrefix() + "message sent");
if (isSynchronous()) {
log.debug(getLogPrefix() + "waiting for reply");
Message msg = getRawReplyMessage(session, queue, sentMessage);
try {
long tsReplyReceived = System.currentTimeMillis();
long tsRequestSent = sentMessage.getJMSTimestamp();
long tsReplySent = msg.getJMSTimestamp();
// }
if (log.isInfoEnabled()) {
log.info(getLogPrefix() + "A) RequestSent [" + DateUtils.format(tsRequestSent) + "]");
log.info(getLogPrefix() + "B) ReplySent [" + DateUtils.format(tsReplySent) + "] diff (~queing + processing) [" + (tsReplySent - tsRequestSent) + "]");
log.info(getLogPrefix() + "C) ReplyReceived [" + DateUtils.format(tsReplyReceived) + "] diff (transport of reply )[" + (tsReplyReceived - tsReplySent) + "]");
// log.info(getLogPrefix()+"C2) msgRcvd.businessProcStartRcvd ["+DateUtils.format(businessProcStartRcvd) +"] ");
// log.info(getLogPrefix()+"D) msgRcvd.jmsTimestamp ["+DateUtils.format(jmsTimestampRcvd) +"] diff ["+(jmsTimestampRcvd-businessProcStartSent)+"]");
// log.info(getLogPrefix()+"E) msgRcvd.businessProcFinishRcvd ["+DateUtils.format(businessProcFinishRcvd)+"] diff ["+(businessProcFinishRcvd-jmsTimestampRcvd)+"] (=time spend on IFSA bus sending result?)");
// log.info(getLogPrefix()+"F) timestampAfterRcvd ["+DateUtils.format(timestampAfterRcvd) +"] diff ["+(timestampAfterRcvd-businessProcFinishRcvd)+"] ");
// log.info(getLogPrefix()+"business processing time (E-C1) ["+(businessProcFinishRcvd-businessProcStartSent)+"] ");
}
// if (businessProcessTimes!=null) {
// businessProcessTimes.addValue(businessProcFinishRcvd-businessProcStartSent);
// }
} catch (JMSException e) {
log.warn(getLogPrefix() + "exception determining processing times", e);
}
if (msg instanceof TextMessage) {
result = ((TextMessage) msg).getText();
} else {
if (msg.getClass().getName().endsWith("IFSAReportMessage")) {
if (msg instanceof IFSAReportMessage) {
IFSAReportMessage irm = (IFSAReportMessage) msg;
if (isThrowExceptions()) {
throw new SenderException(getLogPrefix() + "received IFSAReportMessage [" + ToStringBuilder.reflectionToString(irm) + "], NoReplyReason [" + irm.getNoReplyReason() + "]");
}
log.warn(getLogPrefix() + "received IFSAReportMessage [" + ToStringBuilder.reflectionToString(irm) + "], NoReplyReason [" + irm.getNoReplyReason() + "]");
result = "<IFSAReport>" + "<NoReplyReason>" + irm.getNoReplyReason() + "</NoReplyReason>" + "</IFSAReport>";
}
} else {
log.warn(getLogPrefix() + "received neither TextMessage nor IFSAReportMessage but [" + msg.getClass().getName() + "]");
result = msg.toString();
}
}
if (result == null) {
log.info(getLogPrefix() + "received null reply");
} else {
if (log.isDebugEnabled()) {
if (AppConstants.getInstance().getBoolean("log.logIntermediaryResults", false)) {
log.debug(getLogPrefix() + "received reply [" + result + "]");
} else {
log.debug(getLogPrefix() + "received reply");
}
} else {
log.info(getLogPrefix() + "received reply");
}
}
} else {
result = sentMessage.getJMSMessageID();
}
} catch (JMSException e) {
throw new SenderException(getLogPrefix() + "caught JMSException in sendMessage()", e);
} catch (IfsaException e) {
throw new SenderException(getLogPrefix() + "caught IfsaException in sendMessage()", e);
} finally {
if (sender != null) {
try {
log.debug(getLogPrefix() + "closing sender");
sender.close();
} catch (JMSException e) {
log.debug(getLogPrefix() + "Exception closing sender", e);
}
}
closeSession(session);
}
if (isThrowExceptions() && result != null && result.startsWith("<exception>")) {
throw new SenderException("Retrieved exception message from IFSA bus: " + result);
}
return result;
}
use of nl.nn.adapterframework.extensions.ifsa.IfsaException in project iaf by ibissource.
the class PullingIfsaProviderListener method afterMessageProcessed.
public void afterMessageProcessed(PipeLineResult plr, Object rawMessage, Map threadContext) throws ListenerException {
try {
if (isJmsTransacted() && !(getMessagingSource().isXaEnabledForSure() && JtaUtil.inTransaction())) {
QueueSession session = (QueueSession) threadContext.get(THREAD_CONTEXT_SESSION_KEY);
try {
session.commit();
} catch (JMSException e) {
log.error(getLogPrefix() + "got error committing the received message", e);
}
if (isSessionsArePooled()) {
threadContext.remove(THREAD_CONTEXT_SESSION_KEY);
releaseSession(session);
}
}
} catch (Exception e) {
log.error(getLogPrefix() + "exception in closing or releasing session", e);
}
// 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 id = (String) threadContext.get(IPipeLineSession.messageIdKey);
String cid = (String) threadContext.get(IPipeLineSession.businessCorrelationIdKey);
log.warn(getLogPrefix() + "no original raw message found for messageId [" + id + "] correlationId [" + cid + "], cannot send result");
} else {
QueueSession session = getSession(threadContext);
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);
} finally {
releaseSession(session);
}
}
}
}
use of nl.nn.adapterframework.extensions.ifsa.IfsaException in project iaf by ibissource.
the class IfsaMessagingSource method getReplyReceiver.
/**
* Gets the queueReceiver, by utilizing the <code>getInputQueue()</code> method.<br/>
* For serverside getQueueReceiver() the creating of the QueueReceiver is done
* without the <code>selector</code> information, as this is not allowed
* by IFSA.<br/>
* For a clientconnection, the receiver is done with the <code>getClientReplyQueue</code>
*/
public QueueReceiver getReplyReceiver(QueueSession session, Message sentMessage) throws IfsaException {
QueueReceiver queueReceiver;
String correlationId;
Queue replyQueue;
try {
// IFSA uses the messageId as correlationId
correlationId = sentMessage.getJMSMessageID();
replyQueue = (Queue) sentMessage.getJMSReplyTo();
} catch (JMSException e) {
throw new IfsaException(e);
}
try {
if (hasDynamicReplyQueue() && !useSingleDynamicReplyQueue()) {
queueReceiver = session.createReceiver(replyQueue);
log.debug("created receiver on individual dynamic reply queue");
} else {
String selector = "JMSCorrelationID='" + correlationId + "'";
queueReceiver = session.createReceiver(replyQueue, selector);
log.debug("created receiver on static or shared-dynamic reply queue - selector [" + selector + "]");
}
} catch (JMSException e) {
throw new IfsaException(e);
}
return queueReceiver;
}
Aggregations