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();}}}?