How do I ensure a topic is removed from an ActiveMQ broker - activemq

I am having some trouble with an ActiveMQ broker not removing unused topics from it's memory.
Currently our system is designed to generate many topics dynamically with names designated at runtime. These topics exist for the duration of the applications lifespan and then all consumers and producers for the topic unsubscribe from it. The activemq broker however does not remove these topics from its list (viewable from the web console).
I have edited the default config file broker to set persistent="false" and advisorySupport="false". To me this should remove the topics from the broker but I am obviously missing something.
Can anyone help?

The broker won't remove destinations be default however you can enable this behaviour by configuring a policy to do so. See this help topic on the AMQ website.

Found the problem. The problem wasn't what the applications were doing, it was in the broker configuration. I had to specify
<policyEntry topic=">" producerFlowControl="true" memoryLimit="1mb" gcInactiveDestinations="true" inactiveTimoutBeforeGC="30000">
In the brokers policy map. I don't know how I missed this.

Related

Amazon MQ Destinations Disappearing from ActiveMQ console

I am new to Amazon MQ and ActiveMQ in general. I have configured my broker to have a composite topic that forwards to multiple queues. I have 3 brokers setup this way. Two out of 3 are working as expected. The third though is acting strange. When I go to view my topics and queues the console is empty. I use an identical XML config file for all 3 brokers being the only difference is the topics and queues names. I think I have persistent mode enabled but not sure I have that setup exactly right. I simply uncommented this line in the XML.
<forcePersistencyModeBrokerPlugin persistenceFlag="true"/>
I also have the <destinations> section filled in with the topics and queues I want created upon restart of the broker. I have noticed that they might show up initially but will eventually disappear from the console unless we maintain messages being written to them. I'm not sure what to look for so hopefully someone can give me some guidance or direction.
Ensure you aren't using gcInactiveDestinations="true" anywhere in your broker configuration as this will delete destinations that are inactive and remove them from the console view. You can read more about deleting inactive destinations in the ActiveMQ documentation.

ActiveMQ topics vs RabbitMQ Direct exchanges

We are currently looking at ActiveMQ.
Previously we've used RabbitMQ and in particular Direct exchanges whereby a producer can send a single message to a broker which then fans this out onto 1:N other queues.
We would like a similar setup in ActiveMQ where the broker holds the configuration for which messages go where, rather than the services sending messages directly to specific queues or consumers needing to subscribe to specific topics.
I've dug into the documentation and found Virtual Topic Composite Destinations which looks to provide this functionality.
What I am trying to understand now is if this is the ActiveMQ recommended approach and if there are any pitfalls I should be wary of?
Any ActiveMQ war stories much appreciated!

Is there any way to autorelease topics in ActiveMQ broker

in web console, it seems that AMQ remembers what topics have been used even consumer is 0 for a long time. I think it keeps the thread for the topic active. Is there any way to configure it to release topics after some duration or anything familiar? Thanks
Yes you can configure ActiveMQ Broker to have a policy to delete inactive queues or topics. See details at this page: http://activemq.apache.org/delete-inactive-destinations.html

Can topic messages be made persistent in activemq?

I am very new to JMS and ESB.
I am using activemq as JMS and mule as ESB. When i am forwarding the messages from one queue to another with jms connector parameter "persistentDelivery" as "true" it retains the messages in the target queue after activemq re-start. But in case of forwarding messages from one topic to another,the messages are not retained in the target topic after restart.
Is there any limitation for persistence of messages in case of topic in activemq?
Thanks in advance.
Regards,
Arijit
topics are different in that messages are only retained if there is a durable consumer.
see these for more info...
http://activemq.apache.org/how-do-durable-queues-and-topics-work.html
http://stefanlearninglog.blogspot.com/2009/07/persistent-jms-topics-using-activemq.html
Topics in Activemq are not durable and persistent, so in case one of your consumer is down. You would lost your messages.
To make topic durable and persistent you can create a durable consumer by creating unique client id per consumer.
But again, that is not distributed in case you are following microservices architecture. So multiple pods or replicas will create problem while consuming messages as in no load balancing is possible for durable consumers.
To mitigate this scenario, there is a option of Virtual topics in Activemq.More details have been provided below,
You can send your messages via your producer in topic named as VirtualTopic.MyTopic.
** Note: you must have to follow this naming convention for default activemq configuration. But yes there is also a way to override this naming convention.
Now, to consume your messages via multiple consumers, you have to set naming convention for your consumer side destination as well for eg. Consumer.A.VirtualTopic.MyTopic
Consumer.B.VirtualTopic.MyTopic
These two consumer will receive messages through the topic created above, also with load balancing enabled between multiple replicas of same consumer.
I hope this will help you fixing your problem with activemq topic.

How can I observe what's happening under the hood of ActiveMQ?

I'm experiencing an issue with ActiveMQ and would like to trace/view all ActiveMQ activity. The only log file I can find is one associated with persistent data (if this is turned on). Are there any other log files I view or generate to tell me what's happening under the hood of ActiveMQ and why my consumers aren't consuming messages? Any other suggestions?
Thanks in advance!
activemq has a jmx interface that you can connect to.
this gives us access to consumer counts messages queued dequeue and all sorts of data on memory usage etc.
http://activemq.apache.org/jmx.html
Has all the details to get you started.
I find it excellent in finding out whats going on with activemq.
A quick firing up of jconsole and you will be well on your way to finding out what is going on.
Paul
Agreed. Also you can add the logging interceptor which helps.
Finally for browsing messages, moving them, creating/deleting queues and sending message I highly recommend the new web console for ActiveMQ, Camel and many other plugins: hawtio
Try HawtIO. Assuming you are not using Active MQ 5.9 you can add this feature to your broker. It is a much better web console and a good JMX monitoring utility as well.
http://www.christianposta.com/blog/?p=315