Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void purgeInactiveDestinations() {
- inactiveDestinationsPurgeLock.writeLock().lock();
- try {
- List<Destination> list = new ArrayList<Destination>();
- Map<ActiveMQDestination, Destination> map = getDestinationMap();
- if (isAllowTempAutoCreationOnSend()) {
- map.putAll(tempQueueRegion.getDestinationMap());
- map.putAll(tempTopicRegion.getDestinationMap());
- }
- long maxPurgedDests = this.brokerService.getMaxPurgedDestinationsPerSweep();
- long timeStamp = System.currentTimeMillis();
- for (Destination d : map.values()) {
- d.markForGC(timeStamp);
- if (d.canGC()) {
- list.add(d);
- if (maxPurgedDests > 0 && list.size() == maxPurgedDests) {
- break;
- }
- }
- }
- if (!list.isEmpty()) {
- ConnectionContext context = BrokerSupport.getConnectionContext(this);
- context.setBroker(this);
- for (Destination dest : list) {
- Logger log = LOG;
- if (dest instanceof BaseDestination) {
- log = ((BaseDestination) dest).getLog();
- }
- log.info("{} Inactive for longer than {} ms - removing ...", dest.getName(), dest.getInactiveTimoutBeforeGC());
- try {
- getRoot().removeDestination(context, dest.getActiveMQDestination(), isAllowTempAutoCreationOnSend() ? 1 : 0);
- } catch (Exception e) {
- LOG.error("Failed to remove inactive destination {}", dest, e);
- }
- }
- }
- } finally {
- inactiveDestinationsPurgeLock.writeLock().unlock();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement