jmx4r metaprogramming

A

aidy

Hi,

I am attempting to use the jmx4r library to set an MBean attribute.

From here: http://www.infoq.com/news/2007/06/jmx4r-jruby

It looks like jmx4r uses metaprogramming techniques which disposes
with JMX method calls.

However, I am receiving a

`method_missing': undefined method `active ='

exception, when I attempt to set the attribute.


require 'rubygems'
require 'jmx4r'

include JMX
MBean.establish_connection :host => "xxxxx", :port => 8999
standby_mbean = MBean.find_by_name
"xxx.jmx.monitors:name=hydra.planb.cps,type=JmsQueueStatsMBeanFactory"
standby_mbean.active # == true
begin
standby_mbean.active = false
ensure
MBean.remove_connection
end

Do I need to explicitly invoke an operation?

Thanks

Aidy
 
J

Jeff Mesnil

aidy said:
Hi,

I am attempting to use the jmx4r library to set an MBean attribute.
`method_missing': undefined method `active ='

exception, when I attempt to set the attribute.

This error is strange, there should not be a white space between
'active' and '='. The method to set the value should be 'active=', not
'active ='

This may be due to an error in the description of the MBean.
What you can do:
* check what attributes are exposed by the jmx4r mbean
irb> standby_mbean.attributes
* check what is exposed by the Real JMX MBean object:
irb> JMX::MBean.pretty_print
"xxx.jmx.monitors:name=hydra.planb.cps,type=JmsQueueStatsMBeanFactory"

In you case, you should see a "Value" attribute which is both readable
and writable.

hope that helps,
jeff
 
A

aidy

Hi Jeff

jmx4r is a pretty useful library.
This error is strange, there should not be a white space between
'active' and '='. The method to set the value should be 'active=', not
'active ='

That is a typo, apologies.
This may be due to an error in the description of the MBean.
What you can do:
* check what attributes are exposed by the jmx4r mbean
  irb> standby_mbean.attributes

standby_mbean.attributes.each { |a | puts a.grep /^ac/ }
# => active
* check what is exposed by the Real JMX MBean object:
  irb>  JMX::MBean.pretty_print
"xxx.jmx.monitors:name=hydra.planb.cps,type=JmsQueueStatsMBeanFactory"

very nice
In you case, you should see a "Value" attribute which is both readable
and writable.

writable is false and I am an idiot.

I then successfully invoked a JMX operation on the object returned
with MBean#find_by_name

Thanks

Aidy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,224
Latest member
BettieToom

Latest Threads

Top