2016-03-03 93 views
1

我已經創建一個小的基於Java的應用程序使用ServiceMix 3.0與JBI消息。升級ServiceMix 3.0到ServiceMix 6.0與駱駝

應用程序工作,我們正在使用filepoller(每5分鐘)讀取一個文件位置並將文件轉換爲另一種格式,即。 XML到PDF。

我們使用servixmix filewriter組件在其他文件位置上寫入輸出文件。

現在我們需要升級到Apache ServiceMix 6.0和Camel 2.15.2

我是Apache Camel的新用戶。我已經在servicemix 6.0和camel 2.15.2上完成了一些POC工作,但沒有得到完整的想法,以實現我們的應用場景?

POC像使用文件,計時器,調度程序駱駝組件一樣工作。

CamelContext context = new DefaultCamelContext(); 

    context.addRoutes(new RouteBuilder() { 
     public void configure() throws Exception { 
      from("timer://foo?period=1000").process(new Processor() { 
       @Override 
       public void process(Exchange exchange) throws Exception { 
        System.out.println("Hello world :" 
          + new java.util.Date().toString()); 
       } 
      }); 
     } 

    }); 
    context.start(); 
    Thread.sleep(10000); 
    context.stop(); 

任何人都可以幫助實現上述方案。

請所有建議一些其他方式來獲得場景。

在此先感謝。

回答

1

對於讀取文件,您可以使用filehttp://camel.apache.org/file2.html)組件。對於寫入文件,您也可以使用file組件。 我對你的文件格式一無所知,因此無法通知任何有關它們的處理。

爲了處理您可以使用這些組件:

xslt(轉換XML http://camel.apache.org/xslt.html),

fop(轉換爲PDF http://camel.apache.org/fop.html),

velocity(由模板http://camel.apache.org/velocity.html轉換爲XML)等等。

或者你可以使用一些數據格式:http://camel.apache.org/data-format.htmlBeanIOhttp://camel.apache.org/beanio.html)。

實施例:

from("file://inbox?sortBy=file:name&include=(.*[.](xml|XML)$)&delete=true&preMove=inprogress&delay=300000"). 
    //5 min. delay between poll, consuming only xml file 
     routeId("testRoute") 
    .to("xslt:xsl/transform.xsl") //refers to the file xsl/transform.xsl on the classpath 
    //....... some other transformation here ....... 
    .to("file://outbox"); 
相關問題