mule-esb中的file构建可以设置文件夹路经path,当mule启动后会自动地会对该path路径进行监控。
不知道各位有没有用过这个file构件,如果用过的话,有没有实现过通过程序自动更改path路经,并且立即见效。因为我现在能想到的方法就是更改xml文件,然后重新启动mule服务,这样更新一次path路径生效速度将很慢。不知道有哪位大侠对mule进行研究过,是否知道mule里面提供没提供更改file构件中path路径中的方法。感激不尽。
<flow name="File1">
<file:inbound-endpoint connector-ref="input"
path="C:\file">
<file:filename-wildcard-filter pattern="*.*" />
</file:inbound-endpoint>
<log-component />
<component>
<singleton-object class="com.tt.MessageEngineFileClient" />
</component>
</flow>
不知道各位有没有用过这个file构件,如果用过的话,有没有实现过通过程序自动更改path路经,并且立即见效。因为我现在能想到的方法就是更改xml文件,然后重新启动mule服务,这样更新一次path路径生效速度将很慢。不知道有哪位大侠对mule进行研究过,是否知道mule里面提供没提供更改file构件中path路径中的方法。感激不尽。
<flow name="File1">
<file:inbound-endpoint connector-ref="input"
path="C:\file">
<file:filename-wildcard-filter pattern="*.*" />
</file:inbound-endpoint>
<log-component />
<component>
<singleton-object class="com.tt.MessageEngineFileClient" />
</component>
</flow>
// 启动Spring,初始化Spring Bean
ApplicationContext context = SpringBeanManger
.getApplicationContext();
//将mule配置文件加载到builder里面
SpringXmlConfigurationBuilder builder = new SpringXmlConfigurationBuilder(
"mule-config.xml");
//设置builder的父上下文为Spring的上下文
builder.setParentContext(context);
//根据builder来设置mule的上下文
muleContext = new DefaultMuleContextFactory()
.createMuleContext(builder);
//启动mule服务。
muleContext.start();
* 停止mule上下文服务
*
* @throws MuleException
*/
private static void stopMuleContext() throws MuleException {
if (muleContext != null) {
muleContext.stop();
muleContext = null;
}
}/**
* 启动mule上下文服务
*
* @throws MuleException
*/
private static void startMuleContext() throws MuleException {
SpringXmlConfigurationBuilder builder = new SpringXmlConfigurationBuilder(
"mule-config.xml");
builder.setParentContext(context);
muleContext = new DefaultMuleContextFactory()
.createMuleContext(builder);
muleContext.start();
}/**
* 重新启动mule服务
*
* @param sendDir
*/
public static void restartMuleService(String sendDir) {
try {
MuleLoader.stopMuleContext();
logger.info("ESB关闭成功");
} catch (MuleException e) {
e.printStackTrace();
logger.error("ESB关闭失败");
}
try {
JdomForXml.modifyMuleConfigXml(sendDir);
} catch (Exception e1) {
e1.printStackTrace();
logger.error("'mule-config.xml'配置文件中File构件的path路径更改异常");
}
try {
MuleLoader.startMuleContext();
logger.info("ESB重启成功"); } catch (MuleException e) {
e.printStackTrace();
logger.error("ESB重启失败");
}
}
//mule-config.xml就是mule的配置文件,mule的各项功能都配在里面。
MuleContext muleContext = null;
//将mule配置文件加载到builder里面
SpringXmlConfigurationBuilder builder = new SpringXmlConfigurationBuilder(
"mule-config.xml");
//根据builder来设置mule的上下文
muleContext = new DefaultMuleContextFactory()
.createMuleContext(builder);
//启动mule服务。
muleContext.start();mule 3.X 启动方式: MuleServer muleServer = new MuleServer("bookstore-config.xml");
muleServer.start(true, true);