Question

I am trying to access the MessageHandler endpoint to start and stop the service via JMX. I have the below configuration in my context file. I am able to access the start/stop methods via JConsole.

I am also able to access the endpoint using MBeanServerConnectionFactoryBean from a spring based client.

Now i want to access the endpoint using MBeanProxyFactoryBean so that i can directly invoke the methods as if the bean was local. This doesnt seem to work.

Can you please see my configuation below and suggest whats wrong or what more needs to be done?

Server.xml

    <int-jms:message-driven-channel-adapter id="jmsIn" 
    connection-factory="connectionFactory" concurrent-consumers="3" max-concurrent-consumers="5" 
    destination-name="emsQueue" acknowledge="transacted" channel="jmsInChannel"  
    extract-payload="false" />

 <integration:service-activator id="serviceAct" input-channel="jmsInChannel" output-channel="fileNamesChannel" 
    ref="handler" method="process" />

Client.xml

<bean id="mBeanServerClient" class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
    <property name="serviceUrl" value="service:jmx:rmi:///jndi/rmi://localhost:9004/jmxrmi" />
</bean>

<bean id="jmxClient" class="com.abc.test.IBalJMXClient">
    <property name="connection" ref="mBeanServerClient" />
</bean>
<bean id="remoteJMSMBean" class="org.springframework.jmx.access.MBeanProxyFactoryBean">
    <property name="objectName" value="com.abc.test:name=serviceAct" />
    <property name="server" ref="mBeanServerClient" />
    <property name="proxyInterface" value="com.abc.client.intf.IBalJMSController" />
</bean>

IBalJMSController is the interface in which i have defined start() , stop() and isRunning() methods so that i can access it from any class.

When i try to test it i get invocation exception. Any suggestion will be much appreciated

Was it helpful?

Solution

You asked the same question on the Spring forums; I answered it there; http://forum.springsource.org/showthread.php?127726-Programatically-access-MessageHandlers-exposed-via-JMX

but I'll repeat the answer here...

First, stopping the handler is not the right thing to do - all that will do is unsubscribe from the channel and the messages will get errors "Dispatcher has no subscribers". You need to stop() the message-driven-channel-adapter.

Second, you need to supply the full MBean object name, e.g. "com.irebalpoc.integration:type=ManagedEndpoint,na me=jmsin,bean=endpoint". You can find this in the MBean metadata (e.g. in VisualVM).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top