-
1. Re: Get num of current Topic subscribers
gaohoward Aug 8, 2012 4:37 AM (in response to raymanf)I think you can do this via management interface. Take a look at TopicControl interface, there are some relevant methods like getSubscriptionCount() and so on.
Howard
-
2. Re: Get num of current Topic subscribers
raymanf Aug 8, 2012 4:52 AM (in response to gaohoward)I know they are. but how could I get instance of the right object to use those methods? I am using Spring and JmsTemplate object. ? could you give some concrete example?
thanks.
-
3. Re: Get num of current Topic subscribers
ataylor Aug 8, 2012 4:58 AM (in response to raymanf)you can do this using JMX or JMS, take a look at the user manual and API and also there will be a management example in the distro. If your question is how do you do this with Spring then your best of asking on the spring forums, its not really our domain.
-
4. Re: Get num of current Topic subscribers
raymanf Aug 8, 2012 5:08 AM (in response to ataylor)Actully I already asked in Spring forums and I got this answer:
"
there is no way to get this information from Spring Framework's components as far as I am aware. It might be possible by accessing the HornetQ's components (directly or via JMX), but you will have to consult the HornetQ's documentation as this JMS broker is not supported by VMware."
So mybe you could show me an example how I do it via JMX/JMS?
thanks.
-
5. Re: Get num of current Topic subscribers
ataylor Aug 8, 2012 5:13 AM (in response to raymanf)1 of 1 people found this helpfullike i say there is a JMX and a JMS management example in the distro and also this is fully covered in the user manual, also look at the API for TopicControl
-
6. Re: Get num of current Topic subscribers
raymanf Aug 8, 2012 5:53 AM (in response to ataylor)Hi Andy,
I found some workign example doing it with jboss. I tried to convert it to use in my Spring I think I am on half way but I Guess I miss something.
this is the code:
ObjectName objectName = new ObjectName("org.hornetq:module=JMS,type=Topic,name=marketMakerTopic"); int subscribersCounter = (Integer) server.getAttribute(objectName, new String("listDurableSubscriptions")); logger.info("Utils.getNumOfSubscribersFromTopic(),Current subscribers number=" + subscribersCounter); return subscribersCounter;
and I get exception:
javax.management.InstanceNotFoundException: org.hornetq:module=JMS,type=Topic,name=marketMakerTopic
How could I ge the right instance address? this is how my jmx look like with the hornetQ modules:( I am trying to get the subscribe params for marketMakerTopic )
Domain: org.hornetq org.hornetq:module=Core,type=Acceptor,name="netty" org.hornetq.core.management.impl.AcceptorControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Acceptor,name="netty-throughput" org.hornetq.core.management.impl.AcceptorControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Address,name="jms.queue.DLQ" org.hornetq.core.management.impl.AddressControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Address,name="jms.queue.ExpiryQueue" org.hornetq.core.management.impl.AddressControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Address,name="jms.queue.Notifications" org.hornetq.core.management.impl.AddressControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Address,name="jms.queue.tq" org.hornetq.core.management.impl.AddressControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Address,name="jms.topic.marketMakerTopic" org.hornetq.core.management.impl.AddressControlImpl
Information on the management interface of the MBean
org.hornetq.core.management.impl.AddressControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Queue,address="jms.queue.DLQ",name="jms.queue.DLQ" org.hornetq.core.management.impl.QueueControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Queue,address="jms.queue.ExpiryQueue",name="jms.queue.ExpiryQueue" org.hornetq.core.management.impl.QueueControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Queue,address="jms.queue.Notifications",name="jms.queue.Notifications" org.hornetq.core.management.impl.QueueControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Queue,address="jms.queue.tq",name="jms.queue.tq" org.hornetq.core.management.impl.QueueControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Queue,address="jms.topic.marketMakerTopic",name="b6d454e9-9156-4918-89a7-590166566dbf" org.hornetq.core.management.impl.QueueControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Queue,address="jms.topic.marketMakerTopic",name="ebe13df5-1fbd-497e-9795-59450e4848a8" org.hornetq.core.management.impl.QueueControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Queue,address="jms.topic.marketMakerTopic",name="jms.topic.marketMakerTopic" org.hornetq.core.management.impl.QueueControlImpl
Information on the management interface of the MBean
org.hornetq.core.management.impl.QueueControlImpl
Information on the management interface of the MBean
org.hornetq:module=Core,type=Server org.hornetq.core.management.impl.HornetQServerControlImpl
Information on the management interface of the MBean
org.hornetq:module=JMS,type=ConnectionFactory,name="NettyConnectionFactory" org.hornetq.jms.management.impl.JMSConnectionFactoryControlImpl
Information on the management interface of the MBean
org.hornetq:module=JMS,type=ConnectionFactory,name="NettyThroughputConnectionFactory" org.hornetq.jms.management.impl.JMSConnectionFactoryControlImpl
Information on the management interface of the MBean
org.hornetq:module=JMS,type=Queue,name="DLQ" org.hornetq.jms.management.impl.JMSQueueControlImpl
Information on the management interface of the MBean
org.hornetq:module=JMS,type=Queue,name="ExpiryQueue" org.hornetq.jms.management.impl.JMSQueueControlImpl
Information on the management interface of the MBean
org.hornetq:module=JMS,type=Queue,name="tq" org.hornetq.jms.management.impl.JMSQueueControlImpl
Information on the management interface of the MBean
org.hornetq:module=JMS,type=Server org.hornetq.jms.management.impl.JMSServerControlImpl
Information on the management interface of the MBean
org.hornetq:module=JMS,type=Topic,name="marketMakerTopic" org.hornetq.jms.management.impl.JMSTopicControlImpl
Information on the management interface of the MBean
thanks,
ray.
-
7. Re: Get num of current Topic subscribers
jmesnil Aug 8, 2012 6:13 AM (in response to raymanf)try with new ObjectName("org.hornetq:module=JMS,type=Topic,name=\"marketMakerTopic\"");
the name must be quoted properly.
-
8. Re: Get num of current Topic subscribers
raymanf Aug 8, 2012 6:25 AM (in response to jmesnil)That worked but Now I get: javax.management.AttributeNotFoundException: No such attribute: listAllSubscriptions.
Guess i am not picking the right value in order to retrive the number of the current subsribers:
this is taken from my JMX which describes the attribute I could use:
MBean org.hornetq:module=JMS,type=Topic,name="marketMakerTopic"
Description Information on the management interface of the MBeanAttributes Name
Description
Type
Value
New Value
Address Attribute exposed for management java.lang.String jms.topic.marketMakerTopic Read-only attribute DeliveringCount Attribute exposed for management int 0 Read-only attribute DurableMessageCount Attribute exposed for management int 0 Read-only attribute DurableSubscriptionCount Attribute exposed for management int 0 Read-only attribute JNDIBindings Attribute exposed for management Array of java.lang.String View array Read-only attribute MessageCount Attribute exposed for management long 0 Read-only attribute MessagesAdded Attribute exposed for management long 2 Read-only attribute Name Attribute exposed for management java.lang.String marketMakerTopic Read-only attribute NonDurableMessageCount Attribute exposed for management int 0 Read-only attribute NonDurableSubscriptionCount Attribute exposed for management int 2 Read-only attribute SubscriptionCount Attribute exposed for management int 2 Read-only attribute Temporary Attribute exposed for management boolean false Read-only attribute Operations Name
Return type
Description
listAllSubscriptions [Ljava.lang.Object; List all subscriptions addJNDI void Add the queue to another JNDI binding Parameters id Name Description Class 0
jndiBinding the name of the binding for JNDI java.lang.String removeJNDI void Add the queue to another JNDI binding Parameters id Name Description Class 0
jndiBinding the name of the binding for JNDI java.lang.String listAllSubscriptionsAsJSON java.lang.String List all subscriptions listDurableSubscriptions [Ljava.lang.Object; List only the durable subscriptions listDurableSubscriptionsAsJSON java.lang.String List only the durable subscriptions listNonDurableSubscriptions [Ljava.lang.Object; List only the non durable subscriptions listNonDurableSubscriptionsAsJSON java.lang.String List only the non durable subscriptions listMessagesForSubscription [Ljava.util.Map; List all the message for the given subscription Parameters id Name Description Class 0
queueName the name of the queue representing a subscription java.lang.String listMessagesForSubscriptionAsJSON java.lang.String List all the message for the given subscription Parameters id Name Description Class 0
queueName the name of the queue representing a subscription java.lang.String countMessagesForSubscription int Count the number of messages matching the filter for the given subscription Parameters id Name Description Class 0
clientID the client ID java.lang.String 1
subscriptionName the name of the durable subscription java.lang.String 2
filter a JMS filter (can be empty) java.lang.String dropDurableSubscription void Drop a durable subscription Parameters id Name Description Class 0
clientID the client ID java.lang.String 1
subscriptionName the name of the durable subscription java.lang.String dropAllSubscriptions void Drop all subscriptions from this topic removeMessages int Remove messages matching the given filter from the destination Parameters id Name Description Class 0
filter A JMS message filter (can be empty) java.lang.String Constructors Class
Description
org.hornetq.jms.management.impl.JMSTopicControlImpl Public constructor of the MBean Parameters id Name Description Class 0
p1 org.hornetq.jms.client.HornetQDestination Unknown type 1
p2 org.hornetq.jms.server.JMSServerManager Unknown type 2
p3 org.hornetq.api.core.management.AddressControl Unknown type 3
p4 org.hornetq.core.server.management.ManagementService Unknown type ObjectName: thanks.
-
9. Re: Get num of current Topic subscribers
raymanf Aug 8, 2012 6:26 AM (in response to raymanf)Okie I have chaned this to:
int subscribersCounter = (Integer) server.getAttribute(objectName, new String("SubscriptionCount")); it works now. thank to you all!
-
10. Re: Get num of current Topic subscribers
raymanf Aug 8, 2012 6:28 AM (in response to raymanf)Between the diffrence btw NonDurableSubscriptionCount and SubscriptionCount would be? I mean what exactly "durable" stands for?