Camel Usage Japanese - acromusashi/acromusashi-stream-example GitHub Wiki

Camel-Usage-Japanese

Camelの利用方法

本ページではCamelを用いたイベントルーティングプロセスの利用方法について説明します。

CamelJson2KestrelMain

HttpPostの要素としてJSONを受信し、Kestrelに投入を行うルーティングプロセスです。
起動方法/設定方法は下記の通りです。

1. GitHubからファイルを取得します。
wget https://github.com/downloads/acromusashi/acromusashi-stream-example/acromusashi-stream-example-camel-1.0.0.zip
2. Topologyを起動するノードにファイルを展開します。(camelディレクトリが作成され、その配下に展開されます)
unzip acromusashi-stream-example-camel-1.0.0.zip
3. ルーティング定義ファイルにサーバホストを設定します。
cd camel
vi conf/camel-context-example-json_kestrel.xml

設定内容

<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <!-- Set Host for CamelProcess -->
    <from uri="jetty:http://__CAMEL_HOST__:8080/JSONReceive" />  ## HTTP待ち受けを行うホストを設定
    <bean ref="JsonExtractor" method="extractJson" />
    <!-- Set Kestrel Host -->
    <to uri="kestrel://__KESTREL_HOST__/JSONQueue" />             ## Kestrelが動作しているホストを設定
  </route>
</camelContext>
4.起動スクリプト「startCamelJson2Kestrel.sh」でCamelプロセスを起動します。
chmod +x bin/startCamelJson2Kestrel.sh
bin/startCamelJson2Kestrel.sh

CamelSnmp2KestrelMain

SNMP Trapを受信し、JSONに変換してKestrelに投入を行うルーティングプロセスです。
起動方法/設定方法は下記の通りです。

1. GitHubからファイルを取得します。
wget https://github.com/downloads/acromusashi/acromusashi-stream-example/acromusashi-stream-example-camel-1.0.0.zip
2. Topologyを起動するノードにファイルを展開します。(camelディレクトリが作成され、その配下に展開されます)
unzip acromusashi-stream-example-camel-1.0.0.zip
3. ルーティング定義ファイルにサーバホストを設定します。
cd camel
vi conf/camel-context-example-snmp_kestrel.xml

設定内容

<camelContext xmlns="http://camel.apache.org/schema/spring">
  <dataFormats>
    <xmljson id="xmljson" />
  </dataFormats>
  <route>
    <!-- Set Host for CamelProcess -->
    <from uri="snmp:__CAMEL_HOST__:162?type=TRAP" />      ## SNMPTrap待ち受けを行うホストを設定
    <bean ref="parser" method="parseSNMP" />
    <marshal ref="xmljson" />
    <!-- Set Kestrel Host -->
    <to uri="kestrel://__KESTREL_HOST__/MessageQueue" />   ## Kestrelが動作しているホストを設定
  </route>
</camelContext>
4.起動スクリプト「startCamelSnmp2Kestrel.sh」でCamelプロセスを起動します。
chmod +x bin/startCamelSnmp2Kestrel.sh
bin/startCamelSnmp2Kestrel.sh
⚠️ **GitHub.com Fallback** ⚠️