List of usage examples for org.springframework.integration.store MessageGroup getLastModified
long getLastModified();
From source file:org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler.java
private void forceComplete(MessageGroup group) { Object correlationKey = group.getGroupId(); // UUIDConverter is no-op if already converted Lock lock = this.lockRegistry.obtain(UUIDConverter.getUUID(correlationKey).toString()); boolean removeGroup = true; try {/*from ww w.j av a2 s . co m*/ lock.lockInterruptibly(); try { /* * Refetch the group because it might have changed while we were waiting on * its lock. If the last modified timestamp changed, defer the completion * because the selection condition may have changed such that the group * would no longer be eligible. */ MessageGroup groupNow = this.messageStore.getMessageGroup(group.getGroupId()); long lastModifiedNow = groupNow.getLastModified(); if (group.getLastModified() == lastModifiedNow) { if (groupNow.size() > 0) { if (releaseStrategy.canRelease(groupNow)) { this.completeGroup(correlationKey, groupNow); } else { this.expireGroup(correlationKey, groupNow); } } else { /* * By default empty groups are removed on the same schedule as non-empty * groups. A longer timeout for empty groups can be enabled by * setting minimumTimeoutForEmptyGroups. */ removeGroup = lastModifiedNow <= (System.currentTimeMillis() - this.minimumTimeoutForEmptyGroups); if (removeGroup && logger.isDebugEnabled()) { logger.debug("Removing empty group: " + correlationKey); } } } else { removeGroup = false; if (logger.isDebugEnabled()) { logger.debug("Group expiry candidate (" + correlationKey + ") has changed - it may be reconsidered for a future expiration"); } } } finally { if (removeGroup) { this.remove(group); } lock.unlock(); } } catch (InterruptedException ie) { Thread.currentThread().interrupt(); throw new MessagingException("Thread was interrupted while trying to obtain lock"); } }
From source file:org.springframework.integration.store.AbstractMessageGroupStore.java
public int expireMessageGroups(long timeout) { int count = 0; long threshold = System.currentTimeMillis() - timeout; for (MessageGroup group : this) { long timestamp = group.getTimestamp(); if (this.isTimeoutOnIdle() && group.getLastModified() > 0) { timestamp = group.getLastModified(); }/*from ww w. j ava 2 s. co m*/ if (timestamp <= threshold) { count++; expire(group); } } return count; }