Apache Camel プロジェクトでRestlet コンポーネントを使用すると、 の応答に HTTP ステータス コードを設定できませんonException。
RouteBuilder次のように構成された Camel を検討してください。
onException(Exception.class)
.handled(true)
.process(new FailureResponseProcessor());
from("restlet:http://example.com/foo")
.process(fooProcessor)
.to("file:data/outbox");
で、FailureResponseProcessorRestlet の HTTP 応答コードを設定しようとしています。
public void process(Exchange exchange) throws Exception {
Response response = exchange.getIn()
.getHeader(RestletConstants.RESTLET_RESPONSE,
Response.class);
response.setStatus(Status.SERVER_ERROR_INTERNAL);
}
これは動作しません。HTTP 応答のステータスは常に200 OKです。
HTTP ステータス コードを効果的に設定するには何が必要ですか?