« Return to Thread: DefaultMessageListenerContainer delayed session.commit with locally managed trainasction sessionTransacted=true

DefaultMessageListenerContainer delayed session.commit with locally managed trainasction sessionTransacted=true

by deepinder :: Rate this Message:

Reply to Author | View in Thread

 I required help with DMLC....I have a locally managed setup..."sessiontransacted=true"...

Problem definition: Have the number of listeners=1 always and do a session commit after a given time period=10 seconds....

I have overriden the DMLC with below code snippet...
Is this right approach...as I have overriden a protected method....The problem is that even if the code works as expected....is is not version agnostic....Is there a standard or better solution....and will the below logic work...

protected void doExecuteListener(Session session, Message message)
throws JMSException {

if (startTime == 0) {
startTime = System.currentTimeMillis();
}

long localStart = System.currentTimeMillis();

if (!isAcceptMessagesWhileStopping() && !isRunning()) {
// if (logger.isWarnEnabled()) {
// logger.warn("Rejecting received message because of the listener
// container " +
// "having been stopped in the meantime: " + message);
// }
rollbackIfNecessary(session);
throw new MessageRejectedWhileStoppingException();
}
try {
invokeListener(session, message);
} catch (JMSException ex) {
rollbackOnExceptionIfNecessary(session, ex);
throw ex;
} catch (RuntimeException ex) {
rollbackOnExceptionIfNecessary(session, ex);
throw ex;
} catch (Error err) {
rollbackOnExceptionIfNecessary(session, err);
throw err;
}

long prcEnd = System.currentTimeMillis();

long diff= prcEnd - startTime;

//storing the last timing upon overshoot
if(diff >= commitCount){
LogUtil.info(this, "commiting : " + prcEnd);
startTime = prcEnd;
commitIfNecessary(session, message);
}

iCount++;

}
Forward Message

 « Return to Thread: DefaultMessageListenerContainer delayed session.commit with locally managed trainasction sessionTransacted=true