On Fri, Feb 20, 2009 at 5:12 PM, Nicolas Bouillon <nico...@bouil.org> wrote: > Thank you very much for the patch, and for the velocity ! You are welcome.
Thanks for reporting. If you can test it that would be great. See download page how to use 1.6.1-SNAPSHOT version. eg = Apache SNAPSHOT maven repo and all that stuff. http://camel.apache.org/download.html > > Best regards > > > On Fri, Feb 20, 2009 at 16:12, Claus Ibsen <claus.ib...@gmail.com> wrote: > >> Ah yeah the UnitOfWork works on the processing of the exchange. So it >> completes just as MinaConsumer will write the reponse back to the >> client. >> >> I have commited a new feature into the next version in Camel. >> >> I am afraid I can not see an easy workaround. >> >> You can now set this special header and Camel will close the session >> afterwards >> >> >> exchange.getOut().setHeader(MinaConsumer.HEADER_CLOSE_SESSION_WHEN_COMPLETE, >> true); >> >> >> On Fri, Feb 20, 2009 at 1:52 PM, Nicolas Bouillon <nico...@bouil.org> >> wrote: >> > Claus, >> > >> > Thanks for the tip. Howerver, it dones't seem to work. >> > >> > I have added the following code at the end of my process method : >> > >> > >> > // add a hook to close the session after the exchange >> > exchange.getUnitOfWork().addSynchronization(new Synchronization() >> { >> > >> > @Override >> > public void onComplete(Exchange exchange) { >> > MinaExchange minaExchange = (MinaExchange) exchange; >> > System.out.println("Closing session"); >> > minaExchange.getSession().close().join(); >> > System.out.println("Session closed"); >> > } >> > >> > @Override >> > public void onFailure(Exchange exchange) { >> > >> > } >> > >> > }); >> > >> > >> > But, as i can see as runtime and when debugging step by step in >> > org.apache.camel.component.mina.MinaConsumer, the event onComplete is >> fired >> > before the write to the the socket. So the problem keep the same. >> > >> > I've tried three ways : adding this to my process. Adding to a processor >> > before mine, and after mine. Each time, the onComplete event is called >> > before the MinaHelper.writeBody(session, body, exchange); >> > >> > Regards. >> > Nicolas. >> > >> > On Fri, Feb 20, 2009 at 12:30, Claus Ibsen <claus.ib...@gmail.com> >> wrote: >> > >> >> You can use the Synchronization hooks on the UnitOfWork >> >> >> >> Then you need to route with a processor where you can add the hook >> >> >> >> from("mina").process(new Processor() { >> >> public void process(Exchange exchange) throws >> Exception >> >> { >> >> >> >> exchange.getUnitOfWork().addSynchronization(new >> >> MyMinaMaybeCloseSession()); >> >> } >> >> }).to(xxxx); >> >> >> >> And in the MyMinaMaybeCloseSession you have callbacks for onComplete, >> >> onFailure. >> >> Then you can check in the exchange if the body is that special stop >> >> command and then access the mina session and close it. >> >> >> > >> >> >> >> -- >> Claus Ibsen >> Apache Camel Committer >> >> Open Source Integration: http://fusesource.com >> Blog: http://davsclaus.blogspot.com/ >> > -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/