首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Mule ESB 学习札记(18)Mule和ATOM的整合

2013-09-08 
Mule ESB 学习笔记(18)Mule和ATOM的整合??定时读取特定网址的新rss信息:??jms将消息发送特定的组件??????

Mule ESB 学习笔记(18)Mule和ATOM的整合

?

?

定时读取特定网址的新rss信息:

?

?

jms将消息发送特定的组件

?

?

?

?

?

?

测试类:

import java.io.File;import java.io.InputStream;import java.io.StringReader;import org.apache.commons.io.FileUtils;import org.mule.api.MuleContext;import org.mule.api.client.MuleClient;import org.mule.api.context.MuleContextFactory;import org.mule.config.spring.SpringXmlConfigurationBuilder;import org.mule.context.DefaultMuleContextFactory;public class MuleJmsAtomMain {public static void main(String[] args) {     try {       String configFile = "jms-atom-consume.xml";        System.setProperty("mule.verbose.exceptions","true");        String[] configFileArr = new String[] {configFile };        MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();        MuleContext muleContext = muleContextFactory                .createMuleContext(new SpringXmlConfigurationBuilder(configFileArr));        muleContext.start();            MuleClient client = muleContext.getClient();        FeedReceiver component = (FeedReceiver)muleContext.getRegistry().get("feedConsumer");                String path=MuleJmsAtomMain.class.getClassLoader().getResource("./sample-feed.atom").getFile();               String feed=FileUtils.readFileToString(new File(path));        client.dispatch("jms://feed.in", feed, null);        Thread.sleep(2000);        System.out.println(component.getCount());                 client = muleContext.getClient();         component = (FeedReceiver)muleContext.getRegistry().get("feedConsumer");        component.getReceivedEntries().set(0); //reset since the build reports that it's getting incremented someplace else        client.dispatch("jms://feed.split.in", feed, null);        Thread.sleep(5000);                        System.out.println(component.getCount());} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}}

?

热点排行