Advertisement
Guest User

Untitled

a guest
Feb 21st, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 KB | None | 0 0
  1.     protected void purgeInactiveDestinations() {
  2.         inactiveDestinationsPurgeLock.writeLock().lock();
  3.         try {
  4.             List<Destination> list = new ArrayList<Destination>();
  5.             Map<ActiveMQDestination, Destination> map = getDestinationMap();
  6.             if (isAllowTempAutoCreationOnSend()) {
  7.                 map.putAll(tempQueueRegion.getDestinationMap());
  8.                 map.putAll(tempTopicRegion.getDestinationMap());
  9.             }
  10.             long maxPurgedDests = this.brokerService.getMaxPurgedDestinationsPerSweep();
  11.             long timeStamp = System.currentTimeMillis();
  12.             for (Destination d : map.values()) {
  13.                 d.markForGC(timeStamp);
  14.                 if (d.canGC()) {
  15.                     list.add(d);
  16.                     if (maxPurgedDests > 0 && list.size() == maxPurgedDests) {
  17.                         break;
  18.                     }
  19.                 }
  20.             }
  21.  
  22.             if (!list.isEmpty()) {
  23.                 ConnectionContext context = BrokerSupport.getConnectionContext(this);
  24.                 context.setBroker(this);
  25.  
  26.                 for (Destination dest : list) {
  27.                     Logger log = LOG;
  28.                     if (dest instanceof BaseDestination) {
  29.                         log = ((BaseDestination) dest).getLog();
  30.                     }
  31.                     log.info("{} Inactive for longer than {} ms - removing ...", dest.getName(), dest.getInactiveTimoutBeforeGC());
  32.                     try {
  33.                         getRoot().removeDestination(context, dest.getActiveMQDestination(), isAllowTempAutoCreationOnSend() ? 1 : 0);
  34.                     } catch (Exception e) {
  35.                         LOG.error("Failed to remove inactive destination {}", dest, e);
  36.                     }
  37.                 }
  38.             }
  39.         } finally {
  40.             inactiveDestinationsPurgeLock.writeLock().unlock();
  41.         }
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement