224.8. 完成后关闭会话
当作为服务器执行时,有时要关闭会话,例如:客户端转换已完成。要指示 Camel 关闭会话,您应该添加一个带有键 CamelMinaCloseSessionWhenComplete 设置为布尔值 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);
}
});