Transaction transaction = null;
try {
transaction = storageManager.getTransaction();
SandeshaPolicyBean propertyBean =
SandeshaUtil.getPropertyBean(storageManager.getContext().getAxisConfiguration());
long deleteTime = propertyBean.getSequenceRemovalTimeoutInterval();
if (deleteTime < 0)
deleteTime = 0;
if (deleteTime > 0) {
// Find terminated sequences.
List rmsBeans = storageManager.getRMSBeanMgr().find(finderBean);
deleteRMSBeans(rmsBeans, propertyBean, deleteTime);
finderBean.setTerminated(false);
finderBean.setTimedOut(true);
// Find timed out sequences
rmsBeans = storageManager.getRMSBeanMgr().find(finderBean);
deleteRMSBeans(rmsBeans, propertyBean, deleteTime);
// Remove any terminated RMDBeans.
RMDBean finderRMDBean = new RMDBean();
finderRMDBean.setTerminated(true);
List rmdBeans = storageManager.getRMDBeanMgr().find(finderRMDBean);
Iterator beans = rmdBeans.iterator();
while (beans.hasNext()) {
RMDBean rmdBean = (RMDBean)beans.next();
long timeNow = System.currentTimeMillis();
long lastActivated = rmdBean.getLastActivatedTime();
// delete sequences that have been timedout or deleted for more than
// the SequenceRemovalTimeoutInterval
if ((lastActivated + deleteTime) < timeNow) {
if (log.isDebugEnabled())
log.debug("Deleting RMDBean " + deleteTime + " : " + rmdBean);
storageManager.getRMDBeanMgr().delete(rmdBean.getSequenceID());
}
}
}
// Terminate RMD Sequences that have been inactive.
if (propertyBean.getInactivityTimeoutInterval() > 0) {
RMDBean finderRMDBean = new RMDBean();
finderRMDBean.setTerminated(false);
List rmdBeans = storageManager.getRMDBeanMgr().find(finderRMDBean);
Iterator beans = rmdBeans.iterator();
while (beans.hasNext()) {
RMDBean rmdBean = (RMDBean)beans.next();
long timeNow = System.currentTimeMillis();
long lastActivated = rmdBean.getLastActivatedTime();
if ((lastActivated + propertyBean.getInactivityTimeoutInterval()) < timeNow) {
// Terminate
rmdBean.setTerminated(true);
rmdBean.setLastActivatedTime(timeNow);
if (log.isDebugEnabled())
log.debug(System.currentTimeMillis() + "Marking RMDBean as terminated " + rmdBean);