223.7. 완료 시 세션 닫기
서버 역할을 할 때 때때로 클라이언트 변환이 완료될 때 세션을 종료하려고 합니다. Camel에 세션을 종료하도록 지정하려면 CamelMinaCloseWhenComplete
키가 있는 헤더를 부울 true
값으로 설정해야 합니다.
예를 들어, 아래 예제에서는 bye
메시지를 클라이언트에 다시 작성한 후 세션을 종료합니다.
from("mina2:tcp://localhost:8080?sync=true&textline=true").process(new Processor() { public void process(Exchange exchange) throws Exception { String body = exchange.getIn().getBody(String.class); exchange.getOut().setBody("Bye " + body); exchange.getOut().setHeader(Mina2Constants.MINA_CLOSE_SESSION_WHEN_COMPLETE, true); } });