Red Hat Training

A Red Hat training course is available for Red Hat Fuse

3.12.3. 応答コードの取得

AHC コンポーネントから HTTP 応答コードを取得するには、Exchange.HTTP_RESPONSE_CODE の Out メッセージヘッダーから値を取得します。

Exchange exchange = template.send("ahc:http://www.google.com/search", new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.getIn().setHeader(Exchange.HTTP_QUERY, constant("hl=en&q=activemq"));
            }
   });
   Message out = exchange.getOut();
   int responseCode = out.getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);