Apache Camel에서 놀고 있는데 '간단한 예'단계에서 '이러한 자극적 인 세부 사항'단계로 전환하는 데 몇 가지 문제가 있습니다. 중요한 것은 명시 적으로 이동하여 엔드 포인트를 수정하는 방법입니다.Apache camel : http4 클라이언트 용 쿠키 설정
이 경우 http 클라이언트에 대한 인증 쿠키를 설정해야합니다. 쿠키 저장소 개체가 있지만 클라이언트가이를 사용하도록하는 방법을 알지 못합니다. HttpClientConfigurer
을 사용해 보았지만 HttpClient
은 쿠키 저장소를 노출시키지 않고 어쨌든 호출하지 않는 것 같습니다.
내 현재 코드 :
class CookieClientConfigurer(cs: CookieStore) extends HttpClientConfigurer {
/**
* Not very nice, relying on a runtime type check. But what can you do?
*/
def configureHttpClient(client: HttpClient) {
client match {
case client: AbstractHttpClient => client.setCookieStore(cs)
}
}
}
그리고 호출 : 나는 "https4://rt/REST/1.0/ticket/335729/show"
엔드 포인트의 쿠키 저장소를 설정하는 방법
val username = args(0)
val password = args(1)
val context = new DefaultCamelContext
locally {
// First we need to grab some authentication cookie stuff!
val httpClient = new DefaultHttpClient
val post = new HttpPost("https://rt")
val nvps = List(new BasicNameValuePair("username", username), new BasicNameValuePair("password", password))
post.setEntity(new UrlEncodedFormEntity(asJavaList(nvps)))
httpClient.execute(post)
val ccc = new CookieClientConfigurer(httpClient.getCookieStore())
val httpComp = context.getComponent("https4", classOf[HttpComponent])
httpComp.setHttpClientConfigurer(ccc)
}
val routes = new RouteBuilder {
def configure() = {
from("timer://foo?fixedRate=true&delay=0&period=10000")
.to("https4://rt/REST/1.0/ticket/335729/show")
.to("file://test")
}
}
context.addRoutes(routes)
context.start()
System.in.read()
context.stop()
어떤 생각?
아직 해결 방법이없는 비슷한 문제가 있지만 http4 용 문서는 URI에 cookieStore = customInstance를 추가 할 수 있어야한다고 주장합니다. – kaqqao