150.13. http 메서드 (GET/PATCH/POST/PUT/DELETE/HEAD/OPTIONS/TRACE)를 HTTP 생산자로 설정하는 방법

http PATCH 방법 사용

http PATCH 방법은 Camel 2.11.3 / 2.12.1부터 지원됩니다.

HTTP4 구성 요소는 메시지 헤더를 설정하여 HTTP 요청 메서드를 설정하는 방법을 제공합니다. 예를 들면 다음과 같습니다.

from("direct:start")
  .setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http4.HttpMethods.POST))
  .to("http4://www.google.com")
  .to("mock:results");

메서드는 문자열 상수를 사용하여 조금 더 짧을 수 있습니다.

.setHeader("CamelHttpMethod", constant("POST"))

다음과 같은 Spring 샘플이 있습니다.

<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
  <route>
    <from uri="direct:start"/>
    <setHeader headerName="CamelHttpMethod">
        <constant>POST</constant>
    </setHeader>
    <to uri="http4://www.google.com"/>
    <to uri="mock:results"/>
  </route>
</camelContext>