use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class JdbcTransactionalStorage method getMessageCount.
public int getMessageCount() throws ListenerException {
Connection conn;
try {
conn = getConnection();
} catch (JdbcException e) {
throw new ListenerException(e);
}
try {
PreparedStatement stmt = conn.prepareStatement(getMessageCountQuery);
applyStandardParameters(stmt, false, false);
ResultSet rs = stmt.executeQuery();
if (!rs.next()) {
log.warn(getLogPrefix() + "no message count found");
return 0;
}
return rs.getInt(1);
} catch (Exception e) {
throw new ListenerException("cannot determine message count", e);
} finally {
try {
conn.close();
} catch (SQLException e) {
log.error("error closing JdbcConnection", e);
}
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class JdbcTransactionalStorage method browseMessage.
public Object browseMessage(String messageId) throws ListenerException {
Connection conn;
try {
conn = getConnection();
} catch (JdbcException e) {
throw new ListenerException(e);
}
try {
PreparedStatement stmt = conn.prepareStatement(selectDataQuery);
applyStandardParameters(stmt, messageId, true);
ResultSet rs = stmt.executeQuery();
if (!rs.next()) {
throw new ListenerException("could not retrieve message for messageid [" + messageId + "]");
}
return retrieveObject(rs, 1);
} catch (Exception e) {
throw new ListenerException("cannot deserialize message", e);
} finally {
try {
conn.close();
} catch (SQLException e) {
log.error("error closing JdbcConnection", e);
}
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class PullingJmsListener method getRawMessageFromDestination.
/**
* Retrieves messages from queue or other channel under transaction control, but does no processing on it.
*/
private Object getRawMessageFromDestination(String correlationId, Map threadContext) throws ListenerException {
Session session = null;
Object msg = null;
try {
session = getSession(threadContext);
MessageConsumer mc = null;
try {
mc = getReceiver(threadContext, session, correlationId);
msg = mc.receive(getTimeOut());
while (msg == null && correlationId == null && canGoOn() && !isTransacted()) {
msg = mc.receive(getTimeOut());
}
} catch (JMSException e) {
throw new ListenerException(getLogPrefix() + "exception retrieving message", e);
} finally {
releaseReceiver(mc, correlationId);
}
} finally {
if (sessionNeedsToBeSavedForAfterProcessMessage(msg)) {
threadContext.put(THREAD_CONTEXT_SESSION_KEY, session);
} else {
releaseSession(session);
}
}
return msg;
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class PullingJmsListener method retrieveRawMessage.
/**
* @see nl.nn.adapterframework.core.IPostboxListener#retrieveRawMessage(java.lang.String, java.util.Map)
*/
public Object retrieveRawMessage(String messageSelector, Map threadContext) throws ListenerException {
Session session = null;
try {
session = getSession(threadContext);
MessageConsumer mc = null;
try {
mc = getMessageConsumer(session, getDestination(), messageSelector);
Object result = (getTimeOut() < 0) ? mc.receiveNoWait() : mc.receive(getTimeOut());
return result;
} finally {
if (mc != null) {
try {
mc.close();
} catch (JMSException e) {
log.warn(getLogPrefix() + "exception closing messageConsumer", e);
}
}
}
} catch (Exception e) {
throw new ListenerException(getLogPrefix() + "exception preparing to retrieve message", e);
} finally {
releaseSession(session);
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class JmsMessageBrowser method doBrowse.
protected Message doBrowse(Map selectors) throws ListenerException {
QueueSession session = null;
Message msg = null;
QueueBrowser queueBrowser = null;
try {
session = (QueueSession) createSession();
queueBrowser = session.createBrowser((Queue) getDestination(), getCombinedSelector(selectors));
Enumeration msgenum = queueBrowser.getEnumeration();
if (msgenum.hasMoreElements()) {
msg = (Message) msgenum.nextElement();
}
return msg;
} catch (Exception e) {
throw new ListenerException(e);
} finally {
try {
if (queueBrowser != null) {
queueBrowser.close();
}
} catch (JMSException e1) {
throw new ListenerException("exception closing queueBrowser", e1);
}
closeSession(session);
}
}
Aggregations