[ 
https://issues.apache.org/activemq/browse/AMQ-1255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=41481#action_41481
 ] 

Matthew Roy commented on AMQ-1255:
----------------------------------

I am having similar problems with Advisory queues not disappearing after a 
topic is destroyed, and have found one code path that leaks advisory topics in 
my application.  If I create a topic, add a consumer for said topic, send some 
messages, remove the consumer, and explicitly destroy the topic, there are 
times that advisory topics for the topic are left behind.  The path that lead 
to this situation in my app was in AdvisoryBroker.addConsumer.  When I create 
the topic in the client, no addDestination occurs on the server, but when I add 
the consumer, the addConsumer occurs.  The AdvisoryBroker's addConsumer method 
does:
ActiveMQTopic topic = 
AdvisorySupport.getConsumerAdvisoryTopic(info.getDestination());
consumers.put(info.getConsumerId(), info);
fireConsumerAdvisory(context, topic, info);

Which in turn causes an addDestination to occur within the RegionBroker when 
the advisory event is sent to the ConsumerAdvisoryTopic created above.  What 
seems to be missing is when the removeDestination  method occurs, it looks 
within the AdvisoryBroker's destinations map for an entry for the destination 
getting closed, but in my situation there is no entry for my topic since 
addDestination never occured within the AdvisoryBroker.  This leaves behind the 
ConsumerAdvisoryTopic for my topic within the RegionBroker.

I'm not at all familiar with the inner workings of the Advisory system, but for 
my system I was able to greatly reduce the leaks by changing the addConsumer to 
look like this:

ActiveMQTopic topic = 
AdvisorySupport.getConsumerAdvisoryTopic(info.getDestination());
consumers.put(info.getConsumerId(), info);
if(!destinations.containsKey(info.getDestination())) {
  DestinationInfo destInfo = new DestinationInfo(context.getConnectionId(), 
DestinationInfo.ADD_OPERATION_TYPE, topic);
  fireAdvisory(context, topic, destInfo);
  destinations.put(info.getDestination(), destInfo);
}
 fireConsumerAdvisory(context, topic, info);

By doing this, when a destination is destroyed, the AdvisoryBroker has an entry 
in the map for the destination, so is able to remove the advisory topics from 
the RegionBroker.  I also did something similar in the addProducer.

As I said, this was simply a blind attempt to solve the leak within my 
application without any knowledge of the Advisory system, so I have no idea if 
this will cause side effects or unwanted behavior, but it might point someone 
with more understanding to the source of the problem.


> Advisory queues don't disappear for TEMPORARY queues/topics
> -----------------------------------------------------------
>
>                 Key: AMQ-1255
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1255
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 4.1.0
>            Reporter: Denis Abramov
>            Assignee: Rob Davies
>             Fix For: 5.2.0
>
>
> My ActiveMQ clients create TEMPORARY queues and I have been looking through 
> the active queues recently and I noticed a number of advisory queues are 
> sticking around (mostly ones that have ActiveMQ.Advisory.Producer.*) that 
> refer to the temporary queues that I created. It seems that even though the 
> temporary queues are gone the advisory topics are still there. Over time this 
> looks like it degrades the performance of ActiveMQ.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to