0

我正在尝试访问 MessageHandler 端点以通过 JMX 启动和停止服务。我的上下文文件中有以下配置。我可以通过 JConsole 访问启动/停止方法。

我还可以从基于 spring 的客户端使用 MBeanServerConnectionFactoryBean 访问端点。

现在我想使用 MBeanProxyFactoryBean 访问端点,这样我就可以直接调用方法,就好像 bean 是本地的一样。这似乎不起作用。

您能否在下面查看我的配置并提出问题或需要做些什么?

服务器.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" />

客户端.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 是我定义 start() 、 stop() 和 isRunning() 方法的接口,以便我可以从任何类访问它。

当我尝试测试它时,我得到调用异常。任何建议将不胜感激

4

1 回答 1

1

你在 Spring 论坛上问过同样的问题;我在那里回答;http://forum.springsource.org/showthread.php?127726-Programatically-access-MessageHandlers-exposed-via-JMX

但我会在这里重复答案......

首先,停止处理程序不是正确的做法 - 所做的只是取消订阅频道,消息将收到错误消息“调度程序没有订阅者”。您需要 stop() 消息驱动的通道适配器。

其次,您需要提供完整的 MBean 对象名称,例如“com.irebalpoc.integration:type=ManagedEndpoint,name=jmsin,bean=endpoint”。您可以在 MBean 元数据中找到它(例如在 VisualVM 中)。

于 2012-06-25T14:00:37.650 回答