Agent的实现:
package com.easyway.esb.mule.mbean; import org.mule.api.MuleException; import org.mule.api.agent.Agent; import org.mule.api.lifecycle.InitialisationException; import java.util.Collections; import java.util.List; /** 必须继承自org.mule.api.agent.Agent接口. * Mock agent */ public class AutoTaskAgent implements Agent { private String frobbit; public String getName() { return "Test Agent"; } public void setName(String name) { // nothing to do } public String getDescription() { return "Test JMX Agent"; } public void initialise() throws InitialisationException { // nothing to do } public void start() throws MuleException { // nothing to do } public void stop() throws MuleException { // nothing to do } public void dispose() { // nothing to do } public List<Class<? extends Agent>> getDependentAgents() { return Collections.emptyList(); } public String getFrobbit() { return frobbit; } public void setFrobbit(String frobbit) { this.frobbit = frobbit; } }
mule-mbean-config.xml的配置
<?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:management="http://www.mulesoft.org/schema/mule/management" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/management http://www.mulesoft.org/schema/mule/management/current/mule-management.xsd"> <management:jmx-server> <management:connector-server url="service:jmx:rmi:///jndi/rmi://localhost:9998/server" rebind="false" /> <management:credentials> <spring:entry key="a" value="b"/> <spring:entry key="c" value="c"/> </management:credentials> </management:jmx-server> <management:jmx-log4j/> <management:jmx-mx4j-adaptor jmxAdaptorUrl="http://127.0.0.1:8000"/> <custom-agent name="test-custom-agent" class="com.easyway.esb.mule.mbean.AutoTaskAgent"> <spring:property name="frobbit" value="woggle"/> </custom-agent> <management:jmx-notifications/> <management:log4j-notifications/> <management:chainsaw-notifications chainsawPort="8080" chainsawHost="127.0.0.1"/> </mule>
jmx测试代码:
public class MuleAgentMain { public static void main(String[] args) throws Exception, ConfigurationException { String configFile = "mule-mbean-config.xml"; String[] configFileArr = new String[] {configFile }; MuleContextFactory muleContextFactory = new DefaultMuleContextFactory(); MuleContext muleContext = muleContextFactory .createMuleContext(new SpringXmlConfigurationBuilder(configFileArr)); muleContext.start(); Agent agent = muleContext.getRegistry().lookupObject(JmxAgent.class); System.out.println(agent.getClass()); JmxAgent jmxAgent = (JmxAgent) agent; System.out.println(jmxAgent.isCreateServer()); System.out.println(jmxAgent.isLocateServer()); System.out.println(jmxAgent.isEnableStatistics()); System.out.println(jmxAgent.getConnectorServerUrl()); agent = muleContext.getRegistry().lookupAgent("jmx-log4j"); System.out.println(agent.getClass()); agent = muleContext.getRegistry().lookupAgent("jmx-mx4j-adaptor"); System.out.println( agent.getClass()); Mx4jAgent mx4jAgent = (Mx4jAgent) agent; System.out.println(mx4jAgent.getJmxAdaptorUrl()); agent = muleContext.getRegistry().lookupAgent("jmx-notifications"); System.out.println(agent.getClass()); agent = muleContext.getRegistry().lookupAgent("log4j-notifications"); System.out.println(agent.getClass()); agent = muleContext.getRegistry().lookupAgent("chainsaw-notifications"); System.out.println(agent.getClass()); Log4jNotificationLoggerAgent lnlAgent = (Log4jNotificationLoggerAgent) agent; System.out.println(lnlAgent.getChainsawPort()+" "+lnlAgent.getChainsawHost()); agent = muleContext.getRegistry().lookupAgent("test-custom-agent"); AutoTaskAgent autoTaskAgent=(AutoTaskAgent) agent; System.out.println( autoTaskAgent.getFrobbit()); autoTaskAgent.setFrobbit("aaa"); agent = muleContext.getRegistry().lookupAgent("test-custom-agent"); System.out.println(((AutoTaskAgent)agent).getFrobbit()); } }
相关推荐
Mule ESB基于Java,但它不是传统的Java EE应用服务器,而是采用了更轻量级的Java运行时环境,如Java Management Extensions (JMX) 和Java Naming and Directory Interface (JNDI)。这种设计使得Mule可以在较低的硬件...
Mule ESB是一种开源的企业服务总线(ESB),它允许不同系统之间进行通信,可以处理服务、消息和数据的集成。Mule3.0作为其中的一个版本,提供了广泛的功能和灵活性,支持多种协议和数据格式。 #### 2. 安装Mule ESB...
1. **Mule ESB**:Mule ESB 是一种轻量级的、基于事件驱动的集成平台,它允许开发者将各种不同的系统和服务连接起来,实现数据交换和业务流程自动化。Mule 提供了多种连接器,支持与数据库、Web 服务、文件系统等...
目前市场上有多种 ESB 产品,包括 Oracle 的商业 ESB 产品、Progress 的商业 ESB 产品、TIBCO 的商业 ESB 产品、Mule 的开源 ESB 框架、WSO2 的开源 ESB 框架等。这些产品都提供了基本的 ESB 功能,包括消息传递、...
本教程将引导您了解如何安装、配置和运行Mule 3.0,并通过实例学习其基本用法。 一、环境搭建 1. 下载Mule Standalone:首先,你需要从官方网站(http://www.mulesoft.org/download-mule-esb-community-edition)...
Mule MMC(Mule Management Console)监控管理平台是一款专门针对Mule ESB(Enterprise Service Bus)及其应用程序进行管理和监控的强大工具。该平台不仅提供了全面的服务器、应用程序和服务管理功能,还支持日志...
虽然未提供具体的产品介绍,但通常有如MuleSoft的MULE等开源ESB产品,它们通常具备上述的特性和功能,为企业提供了低成本且高度可定制的集成解决方案。 总结来说,ESB作为企业级集成的重要工具,其主要任务是促进...
management Web console, or management REST servicesCreate a cluster of scalable, and highly-available, RabbitMQ instancesUse RabbitMQ with the Spring Framework, MuleESB, WSO2, and Oracle ...
在 ESB中使用的Mule Agent 可以与任何Oracle / Sun JVM版本6或更高版本一起使用的JVM JDK6代理,并且可以动态地附加到正在运行的Java进程。特征代理方法具有以下几个优点: 防火墙友好由于所有通信都是通过HTTP进行...