22.17.4. 获取响应代码
您可以通过使用 Exchange.HTTP_RESPONSE_CODE
从 Out 邮件标题获取值从 HTTP 组件获取 HTTP 响应代码。
Exchange exchange = template.send("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);