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.
>

Reply via email to