You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Timothy Bish <ta...@gmail.com> on 2012/07/26 01:38:05 UTC

Re: JMXServiceURL for vm://

On Thu, 2012-08-02 at 10:09 +0200, Jamie wrote: 
> Greetings!
> 
> I have ActiveMQ integrated in an  embedded scenario whereby the Broker 
> and ActiveMQ configuration is created programmatically in Java.
> 
> Since I am not intending to queue data over a network, for performance 
> reasons, I am using the URL "vm://appname" in place of localhost when 
> creating the broker.
> 
> brokerService = new BrokerService();)
> brokerService.addConnector("vm://"+brokerName);
> 
> The queuing works perfectly, though I am having difficulty obtaining the 
> QueueViewMBean instance for the purposes of retrieving the current queue 
> size.
> 
> JMXServiceURL url = new 
> JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi"); // 
> what value for this URL?
> 
> It is unclear to me what URL must be used for the JMXServiceURL in the 
> scenario where vm://appname is used (i.e. equivalent of 
> "service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi"). Alternatively, 
> perhaps there is another way to obtain the QueueViewMBean instance. I am 
> not planning on connecting to any remote vm's. I  simply need to use the 
> QueueViewMBean in the same virtual machine as where the brokerService 
> object is created.
> 
> Thanks in advance for your advice.
> 
> Regards
> 
> Jamie

If you search the unit tests code for QueueViewMBean you'll find several
examples of how to get one, here's a snippet from one of the tests:

    private QueueViewMBean getProxyToQueueViewMBean() throws
MalformedObjectNameException, NullPointerException,
            JMSException {
        final ObjectName queueViewMBeanName = new
ObjectName("org.apache.activemq:Type=Queue,Destination="
                + queue.getQueueName() + ",BrokerName=localhost");
        final QueueViewMBean proxy = (QueueViewMBean)
brokerService.getManagementContext().newProxyInstance(
                queueViewMBeanName, QueueViewMBean.class, true);
        return proxy;
    }



-- 
Tim Bish
Sr Software Engineer | FuseSource Corp
tim.bish@fusesource.com | www.fusesource.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Re: JMXServiceURL for vm://

Posted by Raul Kripalani <ra...@fusesource.com>.
What version of AMQ are you testing against?

Have you tried attaching another consumer after running your test which
leaves 10 messages behind? If you have, those 10 messages stay put in the
broker?

Regards,

 *Raúl Kripalani*
*Principal Consultant | FuseSource Corp.
raul@fusesource.com | fusesource.com <http://www.fusesource.com/>
skype: raul.fuse | twitter: @raulvk <http://twitter.com/raulvk>,
@fusenews<http://twitter.com/fusenews>
*
blog: F3 - Flashes From the
Field<http://blog.raulkr.net/?utm_source=fusesourceemail&utm_medium=email&utm_campaign=fusesourcemail>
 | aboutme: http://about.me/raulkripalani

<http://twitter.com/fusenews>

On 2 August 2012 09:45, Jamie <ja...@stimulussoft.com> wrote:

> Thanks, Tim. It worked!
>
> How accurate is the queue size figure? I have a pool of consumers
> retrieving messages from the queue on a constant basis, although strangely
> getQueueSize() is showing 10 messages left on the queue when there should
> be none. Any ideas?
>
> Thanks
>
> Jamie
>
>
> On 2012/07/26 1:38 AM, Timothy Bish wrote:
>
>> >brokerService = new BrokerService();)
>>> >brokerService.addConnector("**vm://"+brokerName);
>>> >
>>> >The queuing works perfectly, though I am having difficulty obtaining the
>>> >QueueViewMBean instance for the purposes of retrieving the current queue
>>> >size.
>>> >
>>> >JMXServiceURL url = new
>>> >JMXServiceURL("service:jmx:**rmi:///jndi/rmi://localhost:**1199/jmxrmi");
>>> //
>>> >what value for this URL?
>>> >
>>> >It is unclear to me what URL must be used for the JMXServiceURL in the
>>> >scenario where vm://appname is used (i.e. equivalent of
>>> >"service:jmx:rmi:///jndi/rmi:**//localhost:1199/jmxrmi").
>>> Alternatively,
>>> >perhaps there is another way to obtain the QueueViewMBean instance. I am
>>> >not planning on connecting to any remote vm's. I  simply need to use the
>>> >QueueViewMBean in the same virtual machine as where the brokerService
>>> >object is created.
>>> >
>>> >Thanks in advance for your advice.
>>> >
>>> >Regards
>>> >
>>> >Jamie
>>>
>> If you search the unit tests code for QueueViewMBean you'll find several
>> examples of how to get one, here's a snippet from one of the tests:
>>
>>      private QueueViewMBean getProxyToQueueViewMBean() throws
>> MalformedObjectNameException, NullPointerException,
>>              JMSException {
>>          final ObjectName queueViewMBeanName = new
>>
>
>
> --
> MailArchiva - Email Archiving and Compliance
> Stimulus Software
> Tel: +1-713-343-8824 ext 100
> Fax: +1-(877)-350-2328
>
>

Re: JMXServiceURL for vm://

Posted by Jamie <ja...@stimulussoft.com>.
Thanks, Tim. It worked!

How accurate is the queue size figure? I have a pool of consumers 
retrieving messages from the queue on a constant basis, although 
strangely getQueueSize() is showing 10 messages left on the queue when 
there should be none. Any ideas?

Thanks

Jamie

On 2012/07/26 1:38 AM, Timothy Bish wrote:
>> >brokerService = new BrokerService();)
>> >brokerService.addConnector("vm://"+brokerName);
>> >
>> >The queuing works perfectly, though I am having difficulty obtaining the
>> >QueueViewMBean instance for the purposes of retrieving the current queue
>> >size.
>> >
>> >JMXServiceURL url = new
>> >JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi"); //
>> >what value for this URL?
>> >
>> >It is unclear to me what URL must be used for the JMXServiceURL in the
>> >scenario where vm://appname is used (i.e. equivalent of
>> >"service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi"). Alternatively,
>> >perhaps there is another way to obtain the QueueViewMBean instance. I am
>> >not planning on connecting to any remote vm's. I  simply need to use the
>> >QueueViewMBean in the same virtual machine as where the brokerService
>> >object is created.
>> >
>> >Thanks in advance for your advice.
>> >
>> >Regards
>> >
>> >Jamie
> If you search the unit tests code for QueueViewMBean you'll find several
> examples of how to get one, here's a snippet from one of the tests:
>
>      private QueueViewMBean getProxyToQueueViewMBean() throws
> MalformedObjectNameException, NullPointerException,
>              JMSException {
>          final ObjectName queueViewMBeanName = new


-- 
MailArchiva - Email Archiving and Compliance
Stimulus Software
Tel: +1-713-343-8824 ext 100
Fax: +1-(877)-350-2328