2016-03-21 4 views
3

キャメルCXF-RSコンポーネントhereの 'connectionTimeout'を設定して、サードパーティサービスでRESTfulな要求を生成しようとしています。デフォルトの30000ミリ秒は長くなります。Camel cxfrs RESTfulクライアント/ ProducerTemplate ConnectionTimeout

<http-conf:conduit name="*.http-conduit"> 
    <http-conf:client ConnectionTimeout="5000"/> 
</http-conf:conduit> 

と私は

を追加しようとしている:私は、私たちの application-contextなど、多くの示唆しているが、 HTTPConduitHTTPClientPolicyクラスを介してデバッグするときには、デフォルト値を変更見ることができないにこれを追加しようとしている

Exchange exchange = template.send("cxfrs://" + url, new Processor() { 
public void process(Exchange exchange) throws Exception { 
    exchange.setPattern(ExchangePattern.InOut); 
    Message inMessage = exchange.getIn(); 
    setupDestinationURL(inMessage); 
    // using the http central client API 
    inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE); 
    // set the Http method 
    inMessage.setHeader(Exchange.HTTP_METHOD, "PUT"); 
    // set the relative path 
    inMessage.setHeader(Exchange.HTTP_PATH, url);     
    // Specify the response class , cxfrs will use InputStream as the response     object type 
    inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, Customer.class); 
    // set a customer header 
    inMessage.setHeader("key", "value"); 
    // since we use the Get method, so we don't need to set the message body 
    inMessage.setBody(null);     
} 
}); 

"?httpClientAPI=true&connectionTimeout=5000" 

をURL文字列のオプションとして使用します。

ご迷惑をおかけして申し訳ございません。

答えて

1

あなたが行ったようにapplication-contexthttp-conf:conduit要素を追加する方法があります。あなたは何を言っていないのですか?

の後に、バックエンドサーバーが応答するには時間がかかります。が接続されています。この場合、ReceiveTimeoutを設定することは、ConnectionTimeoutと同じくらい重要です。

これはRS要求を消費し、サードパーティのRSサーバーを呼び出すサンプルのラクダルートです。 ReceiveTimeoutパラメーターとConnectionTimeoutパラメーターが期待通りに機能します。

<cxf:rsServer id="rsFrontServer" address="..." serviceClass="..."/> 

<cxf:rsClient id="rsBackendClient" address=".../" serviceClass="..."/> 

<http-conf:conduit name="*.http-conduit"> 
    <http-conf:client ReceiveTimeout="5000" ConnectionTimeout="5000"/> 
</http-conf:conduit> 

<camelContext xmlns="http://camel.apache.org/schema/spring"> 
    <route id="front"> 
     <from uri="cxfrs:bean:rsFrontServer"/> 
     <!-- do stuff --> 
     <to uri="cxfrs:bean:rsBackendClient"/> 
    </route> 
</camelContext> 
関連する問題