2016-12-01 7 views
0

私は、OPC-UAエンドポイントから読み取るはずのルートを作成しました。読み出し動作は、タイマに基づいて毎秒実行されるべきである。私が見つけたすべての例では、ルートにはfromという項目が1つしかないことが示されています。私のルートは、次のようになります。タイマーベースのラクダポーリングルートの作成方法は?

<camelContext xmlns="http://camel.apache.org/schema/blueprint"> 
    <route id="opctorest"> 
    <from uri="timer://simpleTimer?period=1000"/> 
    <log message="Triggered Route: opctorest: Sensorreading body: ${body}"/> 
    <to uri="milo-client:tcp://0.0.0.0:4840/freeopcua/server?nodeId=2&amp;namespaceUri=http://examples.freeopcua.github.io"/>   
    <convertBodyTo type="java.lang.String"/>   
    <to uri="stream:out"/> 
    </route> 
</camelContext> 

私はルートを展開するとき、それは毎秒呼び出されますが、コールはto要素で宣言されているので、それはは、エンドポイントにを書き込みます。どのように私はこれを読み取りに変えることができますか?これまでのところ解決策を見つけることができませんでした。ありがとう!

答えて

0

.enrich()を使用して、ルートの途中で読むときに読むことができます。 (ないテスト)に似てあなたの例の何かのために http://camel.apache.org/content-enricher.html

:あなたがエンドポイントをポーリングして、いくつかの間隔に基づいて読むことができるように

<camelContext xmlns="http://camel.apache.org/schema/blueprint"> 
    <route id="opctorest"> 
    <from uri="timer://simpleTimer?period=1000"/> 
    <log message="Triggered Route: opctorest: Sensorreading body: ${body}"/> 
    <enrich uri="milo-client:tcp://0.0.0.0:4840/freeopcua/server?nodeId=2&amp;namespaceUri=http://examples.freeopcua.github.io"/>   
    <convertBodyTo type="java.lang.String"/>   
    <to uri="stream:out"/> 
    </route> 
</camelContext> 
+0

ところでがPollingEnrichもあります。おそらくそれはあなたにはうってつけでしょうか? –

+0

それはトリック、ありがとうございます:) – Fluffy

関連する問題