1. 程式人生 > >Apache Camel 中camel配置檔案引入其他xml檔案介紹--將camel配置檔案拆分後並引用

Apache Camel 中camel配置檔案引入其他xml檔案介紹--將camel配置檔案拆分後並引用

1、rest

可以在新檔案中用<restContext/>標籤

例如:需要匯入的檔案myCoolRests.xml,內容為

<restContext id="myCoolRest" xmlns="http://camel.apache.org/schema/spring">
  <rest uri="/say/hello">
    <get>
      <to uri="direct:hello"/>
    </get>
  </rest>
</restContext>

在camel的配置檔案中用spring匯入,如:<import resource="myCoolRests.xml" />

然後在<camelContext/>標籤中通過<restContextRef>標籤引入,標籤中引數ref等於<restContext/>的id值。

例如:

<camelContext xmlns="http://camel.apache.org/schema/spring">
 
 
  <restContextRef ref="myCoolRest"/>
 
 
  <rest uri="/say/bye">
    <get consumes="application/json">
      <to uri="direct:bye"/>
    </get>
    <post>
      <to uri="mock:update"/>
    </post>
  </rest>
 
  <route>
    <from uri="direct:hello"/>
    <transform>
      <constant>Hello World</constant>
    </transform>
  </route>
  <route>
    <from uri="direct:bye"/>
    <transform>
      <constant>Bye World</constant>
    </transform>
  </route>
</camelContext>

注意:<restContextRef>標籤可以在<camelContext>標籤中重複使用。

2、route

可以在新檔案中使用<routeContext>標籤

例如:需要匯入的檔案myCoolRoutes.xml,內容為

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
    ">
 
    <!-- this is an included XML file where we only the the routeContext -->
    <routeContext id="myCoolRoutes" xmlns="http://camel.apache.org/schema/spring">
        <!-- we can have a route -->
        <route id="cool">
            <from uri="direct:start"/>
            <to uri="mock:result"/>
        </route>
        <!-- and another route, you can have as many your like -->
        <route id="bar">
            <from uri="direct:bar"/>
            <to uri="mock:bar"/>
        </route>
    </routeContext>
 
</beans>

在camel的配置檔案中用spring匯入,如:<import resource="myCoolRoutes.xml" />

然後在<camelContext/>標籤中通過<routeContextRef>標籤引入,標籤中引數ref等於<restContext/>的id值。

例如:

<!-- import the routes from another XML file -->
<import resource="myCoolRoutes.xml"/>
 
<camelContext xmlns="http://camel.apache.org/schema/spring">
 
    <!-- refer to a given route to be used -->
    <routeContextRef ref="myCoolRoutes"/>
 
    <!-- we can of course still use routes inside camelContext -->
    <route id="inside">
        <from uri="direct:inside"/>
        <to uri="mock:inside"/>
    </route>
</camelContext>

注意:同<restContextRef>標籤一樣<routeContextRef>標籤可以在<camelContext>標籤中重複使用。

相關推薦

Apache Camel camel配置檔案引入其他xml檔案介紹--camel配置檔案拆分引用

1、rest 可以在新檔案中用<restContext/>標籤 例如:需要匯入的檔案myCoolRests.xml,內容為 <restContext id="myCoolRest" xmlns="http://camel.apache.org/schema

前端上傳檔案前預覽,.netbase64位轉換為圖片儲存到本地

前端上傳檔案前預覽 <img src="" id="img-change" width="200px" height="200px" id="filePath" name="filePath"> <input type="file" id="file" style="displ

android 建立檔案和建立資料夾、assets下檔案複製到指定目錄下

1.獲取APP當前目錄路徑: public String getPath(){ File fileDire = getFilesDir();//獲取../data/應用的包名/fil

gradle檔案引入其他gradle檔案

背景:     安卓專案中,gradle檔案也逐漸變得臃腫起來,需要分開管理,否則一大堆在一起,就很難維護了。 解決方案:   採用apply from: 'xx.gradle'這樣的語句就可以引入其他gradle檔案了。 Demo(整合aspectj):     

Android學習筆記——NDKC++標準庫、STL的配置;Include其他標頭檔案

以下所有是基於Eclipse的,使用命令列的繞道。 1、STL的使用,以stlport為例官方的說法是隻需要在Application.mk檔案中新增如下一行即可 Application.mk程式碼   APP_STL := stlport_static   即可,可是

Camel配置不同servlet的一種方法二

  繼上一篇“Camel中配置不同servlet的一種方法”之後,經過專案實踐又發現了一種更簡單的配置不同servlet請求的方法,具體如下: 在web.xml中配置 <!-- Camel servlet --> <servlet> &l

(一)配置mac環境下的JAVA_HOME 與 (二)配置maven (三)Mac上jdk的配置 (四)在terminal執行.class檔案

(一)mac環境下,echo $JAVA_HOME 一般輸出為空,但有時候某些構件會需要有javahome的配置,這時就需要把Java home配置好。 步驟: 1, 命令列輸入: /usr/libexec/java_home 我的環境輸出是 /Library/Java/JavaVi

springboot程式logback日誌基本配置,多個包不同日誌級別輸入到檔案

日誌是程式中必不可少的內容。依據日誌我們可以有效診斷程式bug,統計使用者訪問和各主要功能的使用頻率時間段等資訊。因此我們會需要不同package使用不同的日誌級別,以及不同業務的日誌輸出到不同的檔案。下面本文簡要概述如何使用logback將不同包的不同級別日誌輸出到info1.txt中

springcloud:config配置中心(多配置檔案引入

解決客戶端引入多個檔案問題。 比如我一個服務需要載入公共的配置(資料庫/redis連線),還要載入私有配置,我希望把他們放兩個私有檔案中分別載入。可是發現client只會讀取bootstrap.properties中配置的spring.cloud.config.name相應的配置。如何解決這

vue頁面引入其他vue元件

比如說有兩個vue元件,app.vue,test.vue 要在app.vue中使用test.vue元件,則需要在app.vue元件中進行註冊: 下面舉一個簡單的例子幫助理解: test.vue: <templete> <div class="t

關於一個檔案的全域性變數在其他檔案的使用

錯誤:多重定義 和 xxx變數已經在xxx.obj中定義 當在一個.cpp檔案中定義了一個全域性變數之後,需要在其他檔案中使用時,需要用到關鍵字extern 當使用extern修飾一個變數時,例如extern int x;   代表當前變數x 的定義來自於其他檔案,當

SHELL指令碼 移動mv指定目錄的所有檔案其他目錄

遞迴寫的,不太好看,反正能用,多擔待 #!/bin/bash function func { for name in $1* do if [ -d "$name" ] then # echo "$name is a d" func $name/ $2 $p elif

SSM專案引入其他jar找不到,解決辦法(jodconverter-2.2.2.jar)

安裝到mvn裡面 mvn install:install-file -Dfile=jodconverter-2.2.2.jar -DgroupId=org.improve4meaven.jodconverter -DartifactId=jodconverter -Dversion= -

node.js檔案引入

//方法一: const fs = require('fs') //讀取內容 fs.readFile('./成績.txt','utf8',(err,datastr)=>{ //轉陣列 //處理 var arr = datastr.split('

ymal引入其他的yml或properties

在開發過程中如果需要其他的配置檔案,全部寫到application.yml中感覺太臃腫,這時,我們可以將yml拆分成多個yml或者properties檔案 在配置檔案目錄(如:resources)

配置檔案引入struts-2.5.dtd不生效,無提示

1、找到引入的Struts-2.5.dtd(也可能是其他Struts的dtd) 2、把struts-2.5.dtd複製到本地(如果不能複製那就需要到網上去下載) 3、步驟: ①:點Window–>Preferences ②:在Preference中輸入x

HTML檔案裡把所有的css、js檔案引入其他的HTML檔案引入該頁面,可以使用該頁面引入的css和js

怎樣將一個HTML檔案裡把所有的css、js檔案引入後,然後其他的HTML檔案就不需要在進行引入了 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"

springBoot專案,如何根據不同的環境,打包不同的配置檔案

版權宣告:轉發請註明,謝謝配合 https://blog.csdn.net/qq_31289187/article/details/85116371 1、建立springboot專案,然後建立不同的resource 2、application.properties加上一個標誌,

如何在 Maven 工程引入其他jar包 生效?(以 Netty 為例)

1.到 Maven 官網  查詢 相關 框架 https://mvnrepository.com/artifact/io.netty/netty-all/4.1.32.Final 2.把相關 Xml體 複製到  Maven 的 pom.xml 中    &nbs

PyCharm整合環境,在python檔案引入numpy包出錯

1、在ELM_python3.5.4.py中引入numpy包,出錯,如下圖1所示 2、原因 原因是pycharm所使用的直譯器並不是已經安裝的python3.5,而是專案自帶的python.exe直譯器,並且只有兩個模組pip和setuptools,許