When broker is starting up with existing JVM (non-ActiveMQ created)
MBeanServer, and isSlave gets called by a scheduled job, I get
InstanceNotFoundException on the client side. Nothing declares this checked
exception will get thrown so compiler won't let me catch it. Once ActiveMQ
is fully up, same call returns nicely.

Here is the relevant client code (from
ConnectionsMonitorImpl.testAmqConnections):


116:  JMXServiceURL jmxUrl = new JMXServiceURL(jmxUrlString);
117:  jmxc = connectWithTimeout(jmxUrl, 5, TimeUnit.SECONDS);
118:  MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
119:  ObjectName mbeanName = new
ObjectName("org.apache.activemq:BrokerName=localhost,Type=Broker");
120:  BrokerViewMBean mbeanProxy = JMX.newMBeanProxy(mbsc, mbeanName,
BrokerViewMBean.class, true);
121:  boolean isSlave = mbeanProxy.isSlave();


Here are Java client and ActiveMQ log fragments from interval around moment
when InstanceNotFoundException gets thrown:


Java client log:
[2012-01-05 23:04:42.957] 80220 [scheduler_Worker-7] ERROR
org.quartz.core.ErrorLogger - Job (DEFAULT.monitorAmqConnections threw an
exception.
org.quartz.SchedulerException: Job threw an unhandled exception.
        at org.quartz.core.JobRunShell.run(JobRunShell.java:227)
~[quartz-1.8.5.jar:na]
        at
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
[quartz-1.8.5.jar:na]
Caused by:
org.springframework.scheduling.quartz.JobMethodInvocationFailedException:
Invocation of method 'testAmqConnections' on target class [class
foo.bar.ConnectionsMonitorImpl]
 failed; nested exception is java.lang.reflect.UndeclaredThrowableException
        at
org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:273)
~[spring-context-support-3.0.6.RELEASE.jar:3
.0.6.RELEASE]
        at
org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
~[spring-context-support-3.0.6.RELEASE.jar:3.0.6.RELEASE]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
~[quartz-1.8.5.jar:na]
        ... 1 common frames omitted
Caused by: java.lang.reflect.UndeclaredThrowableException: null
        at $Proxy144.isSlave(Unknown Source) ~[na:na]
        at
foo.bar.ConnectionsMonitorImpl.testAmqConnections(ConnectionsMonitorImpl.java:121)
~[ConnectionsMonitorImpl.class:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[na:1.6.0_29]
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
~[na:1.6.0_29]
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
~[na:1.6.0_29]
        at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_29]
        at
org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
~[spring-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
        at
org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:264)
~[spring-context-support-3.0.6.RELEASE.jar:3
.0.6.RELEASE]
        at
org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:87)
~[spring-context-support-3.0.6.RELEASE.jar:3.0.6.RELEASE]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:217)
~[quartz-1.8.5.jar:na]
        ... 1 common frames omitted
Caused by: javax.management.InstanceNotFoundException:
org.apache.activemq:BrokerName=localhost,Type=Broker
        at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1094)
~[na:1.6.0_29]
        at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:662)
~[na:1.6.0_29]
        at
com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:638)
~[na:1.6.0_29]
        at
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1404)
~[na:1.6.0_29]
        at
javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:72)
~[na:1.6.0_29]
        at
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1265)
~[na:1.6.0_29]
        at
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1360)
~[na:1.6.0_29]
        at
javax.management.remote.rmi.RMIConnectionImpl.getAttribute(RMIConnectionImpl.java:600)
~[na:1.6.0_29]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[na:1.6.0_29]
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
~[na:1.6.0_29]
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
~[na:1.6.0_29]
        at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_29]
        at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:303)
~[na:1.6.0_29]
        at sun.rmi.transport.Transport$1.run(Transport.java:160)
~[na:1.6.0_29]
        at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
~[na:1.6.0_29]
        at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
~[na:1.6.0_29]
        at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
~[na:1.6.0_29]
        at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
~[na:1.6.0_29]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
~[na:1.6.0_29]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:909)
~[na:1.6.0_29]
        at java.lang.Thread.run(Thread.java:662) ~[na:1.6.0_29]
        at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
~[na:1.6.0_29]
        at
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
~[na:1.6.0_29]
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
~[na:1.6.0_29]
        at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source) ~[na:na]
        at
javax.management.remote.rmi.RMIConnectionImpl_Stub.getAttribute(Unknown
Source) ~[na:1.6.0_29]
        at
javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getAttribute(RMIConnector.java:878)
~[na:1.6.0_29]
        at
javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:272)
~[na:1.6.0_29]
        at $Proxy144.isSlave(Unknown Source) ~[na:na]
        at
foo.bar.ConnectionsMonitorImpl.testAmqConnections(ConnectionsMonitorImpl.java:121)
~[ConnectionsMonitorImpl.class:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[na:1.6.0_29]
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
~[na:1.6.0_29]
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
~[na:1.6.0_29]
        at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_29]
        at
org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
~[spring-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
        at
org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:264)
~[spring-context-support-3.0.6.RELEASE.jar:3
.0.6.RELEASE]
        at
org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
~[spring-context-support-3.0.6.RELEASE.jar:3.0.6.RELEASE]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
~[quartz-1.8.5.jar:na]
        ... 1 common frames omitted


ActiveMQ log:
2012-01-05 23:04:42,433 | INFO  | Refreshing
org.apache.activemq.xbean.XBeanBrokerFactory$1@1c0c5e3d: startup date [Thu
Jan 05 23:04:42 CET 2012]; root of context hierarchy |
org.apache.activemq.xbean.XBeanB
rokerFactory$1 | WrapperSimpleAppMain
2012-01-05 23:04:43,328 | WARN  | destroyApplicationContextOnStop parameter
is deprecated, please use shutdown hooks instead |
org.apache.activemq.xbean.XBeanBrokerService | WrapperSimpleAppMain
2012-01-05 23:04:43,336 | INFO  |
PListStore:/data/activemq_data/localhost/tmp_storage started |
org.apache.activemq.store.kahadb.plist.PListStore | WrapperSimpleAppMain
2012-01-05 23:04:43,386 | INFO  | Using Persistence Adapter:
KahaDBPersistenceAdapter[/data/activemq_data/kahadb] |
org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain
2012-01-05 23:04:44,221 | INFO  | KahaDB is version 3 |
org.apache.activemq.store.kahadb.MessageDatabase | WrapperSimpleAppMain
2012-01-05 23:04:44,291 | INFO  | Recovering from the journal ... |
org.apache.activemq.store.kahadb.MessageDatabase | WrapperSimpleAppMain
2012-01-05 23:04:44,293 | INFO  | Recovery replayed 1 operations from the
journal in 0.041 seconds. |
org.apache.activemq.store.kahadb.MessageDatabase | WrapperSimpleAppMain
2012-01-05 23:04:44,318 | INFO  | ActiveMQ 5.5.0 JMS Message Broker
(localhost) is starting | org.apache.activemq.broker.BrokerService |
WrapperSimpleAppMain
2012-01-05 23:04:44,318 | INFO  | For help or more information please see:
http://activemq.apache.org/ | org.apache.activemq.broker.BrokerService |
WrapperSimpleAppMain
2012-01-05 23:04:44,707 | INFO  | Listening for connections at:
tcp://foo02:61616 |
org.apache.activemq.transport.TransportServerThreadSupport |
WrapperSimpleAppMain
2012-01-05 23:04:44,708 | INFO  | Connector openwire Started |
org.apache.activemq.broker.TransportConnector | WrapperSimpleAppMain
2012-01-05 23:04:44,717 | INFO  | ActiveMQ JMS Message Broker (localhost,
ID:foo02-32296-1325801084346-0:1) started |
org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain
2012-01-05 23:04:44,825 | INFO  | jetty-7.1.6.v20100715 |
org.eclipse.jetty.util.log | WrapperSimpleAppMain
2012-01-05 23:04:44,905 | WARN  | Can't reuse
/tmp/Jetty_0_0_0_0_8161_admin__admin__9l5s6p, using
/tmp/Jetty_0_0_0_0_8161_admin__admin__9l5s6p_2948067291497697879 |
org.eclipse.jetty.util.log | WrapperSimple
AppMain
2012-01-05 23:04:45,219 | INFO  | ActiveMQ WebConsole initialized. |
org.apache.activemq.web.WebConsoleStarter | WrapperSimpleAppMain
2012-01-05 23:04:45,366 | INFO  | Initializing Spring FrameworkServlet
'dispatcher' | /admin | WrapperSimpleAppMain
2012-01-05 23:04:45,652 | INFO  | ActiveMQ Console at
http://0.0.0.0:8161/admin | org.eclipse.jetty.util.log |
WrapperSimpleAppMain
2012-01-05 23:04:45,652 | WARN  | Can't reuse
/tmp/Jetty_0_0_0_0_8161_camel__camel__.3v7y27, using
/tmp/Jetty_0_0_0_0_8161_camel__camel__.3v7y27_8560113755856480905 |
org.eclipse.jetty.util.log | WrapperSimp
leAppMain
2012-01-05 23:04:45,762 | INFO  | Initializing Spring root
WebApplicationContext | /camel | WrapperSimpleAppMain
2012-01-05 23:04:45,803 | INFO  | OSGi environment not detected. |
org.apache.camel.spring.handler.CamelNamespaceHandler | WrapperSimpleAppMain
2012-01-05 23:04:46,550 | INFO  | Apache Camel 2.7.0 (CamelContext: camel)
is starting | org.apache.camel.spring.SpringCamelContext |
WrapperSimpleAppMain
2012-01-05 23:04:46,557 | INFO  | JMX enabled. Using
ManagedManagementStrategy. | org.apache.camel.spring.SpringCamelContext |
WrapperSimpleAppMain
2012-01-05 23:04:47,023 | INFO  | Found 5 packages with 16 @Converter
classes to load |
org.apache.camel.impl.converter.AnnotationTypeConverterLoader |
WrapperSimpleAppMain
2012-01-05 23:04:47,041 | INFO  | Loaded 152 type converters in 0.344
seconds | org.apache.camel.impl.converter.DefaultTypeConverter |
WrapperSimpleAppMain
2012-01-05 23:04:47,357 | INFO  | Connector vm://localhost Started |
org.apache.activemq.broker.TransportConnector | WrapperSimpleAppMain
2012-01-05 23:04:47,430 | INFO  | Route: route1 started and consuming from:
Endpoint[activemq://example.A] | org.apache.camel.spring.SpringCamelContext
| WrapperSimpleAppMain
2012-01-05 23:04:47,441 | INFO  | Total 1 routes, of which 1 is started. |
org.apache.camel.spring.SpringCamelContext | WrapperSimpleAppMain
2012-01-05 23:04:47,441 | INFO  | Apache Camel 2.7.0 (CamelContext: camel)
started in 0.891 seconds | org.apache.camel.spring.SpringCamelContext |
WrapperSimpleAppMain
2012-01-05 23:04:48,359 | INFO  | Camel Console at
http://0.0.0.0:8161/camel| org.eclipse.jetty.util.log |
WrapperSimpleAppMain
2012-01-05 23:04:48,360 | WARN  | Can't reuse
/tmp/Jetty_0_0_0_0_8161_demo__demo__uj3swb, using
/tmp/Jetty_0_0_0_0_8161_demo__demo__uj3swb_94329410284537106 |
org.eclipse.jetty.util.log | WrapperSimpleAppMai
n
2012-01-05 23:04:48,368 | INFO  | ActiveMQ Web Demos at
http://0.0.0.0:8161/demo | org.eclipse.jetty.util.log | WrapperSimpleAppMain
2012-01-05 23:04:48,368 | WARN  | Can't reuse
/tmp/Jetty_0_0_0_0_8161_fileserver__fileserver__rlvn9v, using
/tmp/Jetty_0_0_0_0_8161_fileserver__fileserver__rlvn9v_6652368536172500759
| org.eclipse.jetty.util
.log | WrapperSimpleAppMain
2012-01-05 23:04:48,376 | INFO  | RESTful file access application at
http://0.0.0.0:8161/fileserver | org.eclipse.jetty.util.log |
WrapperSimpleAppMain
2012-01-05 23:04:48,407 | INFO  | Started
SelectChannelConnector@0.0.0.0:8161 | org.eclipse.jetty.util.log |
WrapperSimpleAppMain


Would having ActiveMQ start MBeanServer make any difference?

I'm using following solution to apply JMX connection timeouts:
http://weblogs.java.net/blog/emcmanus/archive/2007/05/making_a_jmx_co.html

Regards,
Stevo.


On Thu, Jan 5, 2012 at 1:23 PM, Stevo Slavić <ssla...@gmail.com> wrote:

> Great, thank you very much Dejan!
>
> This property is not listed on the ActiveMQ JMX Reference page:
> http://activemq.apache.org/jmx.html#JMX-ActiveMQMBeansReference
>
> Found more info in the source and contributed fix for javadoc typo ( see
> https://issues.apache.org/jira/browse/AMQ-3652 ). FOSS rulz!
>
> Regards,
> Stevo.
>
>
> On Thu, Jan 5, 2012 at 12:01 PM, Dejan Bosanac <de...@nighttale.net>wrote:
>
>> It does, and you have "Slave" JMX attribute on broker object.
>>
>> Regards
>> --
>> Dejan Bosanac - http://twitter.com/dejanb
>> -----------------
>> The experts in open source integration and messaging -
>> http://fusesource.com
>> ActiveMQ in Action - http://www.manning.com/snyder/
>> Blog - http://www.nighttale.net
>>
>>
>> On Wed, Jan 4, 2012 at 8:20 PM, Stevo Slavić <ssla...@gmail.com> wrote:
>>
>> > Hello ActiveMQ community,
>> >
>> > Is there a way to check that a slave, in shared filesystem storage
>> > master/slave setup which is awaiting lock to become available, is up?
>> Does
>> > JMX interface start early enough, before lock is acquired?
>> >
>> > Regards,
>> > Stevo.
>> >
>>
>
>

Reply via email to