Hi

I dont think you currently can both CLOSE a session and return a
response when sync=true.

Could you file a JIRA request for this?
http://camel.apache.org/support.html

We could introduce some special header you can add to the Message so
Camel knows that it should close the session when its finished writing
the response.




On Fri, Feb 20, 2009 at 11:46 AM, Nicolas Bouillon <nico...@bouil.org> wrote:
> Hi,
>
> I'm new to Apache Camel and Mina. I'm writing a simple tcp sever and i'm
> facing a problem : i don't know how to close a Mina Endpoint Session. I use
> Camel 1.5.0 (available at maven official repository)
>
> The workflow is : the client send a "Logout" command, then the server says
> "Bye" and the _server_ close the connection. It's like and FTP server does.
>
> my route is this way configured :
> <route>
>        <from ref="myMinaEndpoint" />
>        <to uri="myProcessor" />
> </route>
>
> The minaEndPoint URL is
> mina:tcp://localhost:1802?textline=false&sync=true&minaLogger=false&codec=myCodec
>
> In my processor, i do in the process(Exchange exchange) method :
> MinaExchange minaExchange = (MinaExchange) exchange;
> // ...
> minaExchange.getOut().setBody(myResponse);
>
> and the classic request-response works well
>
> but if i add at the end if the case of a logout request
>  minaExchange.getSession().close();
> the tcp session is closed, but the response ("Bye") is not sent. I got an
> exception on server side :
>
> 230583 [AnonymousIoService-11] WARN
> org.apache.camel.component.mina.MinaConsumer$ReceiveHandler - [/
> 192.168.244.87:54868] Unexpected exception from exceptionCaught handler.
> org.apache.camel.CamelException: org.apache.camel.CamelExchangeException:
> Could not write body on the exchange: Exchange[Message:
> com.dclgroup.eurodns.epp.server.eppdatag...@109dc35]
>    at
> org.apache.camel.component.mina.MinaConsumer$ReceiveHandler.exceptionCaught(MinaConsumer.java:88)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.exceptionCaught(AbstractIoFilterChain.java:564)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain.callNextExceptionCaught(AbstractIoFilterChain.java:345)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain.access$1000(AbstractIoFilterChain.java:53)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.exceptionCaught(AbstractIoFilterChain.java:643)
>    at
> org.apache.mina.common.IoFilterAdapter.exceptionCaught(IoFilterAdapter.java:75)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain.callNextExceptionCaught(AbstractIoFilterChain.java:345)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain.access$1000(AbstractIoFilterChain.java:53)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.exceptionCaught(AbstractIoFilterChain.java:643)
>    at
> org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:224)
>    at
> org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:264)
>    at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>    at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>    at
> org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
>    at java.lang.Thread.run(Thread.java:619)
> Caused by: org.apache.camel.CamelExchangeException: Could not write body on
> the exchange: Exchange[Message:
> com.dclgroup.eurodns.epp.server.eppdatag...@109dc35]
>    at
> org.apache.camel.component.mina.MinaHelper.writeBody(MinaHelper.java:47)
>    at
> org.apache.camel.component.mina.MinaConsumer$ReceiveHandler.messageReceived(MinaConsumer.java:131)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived(AbstractIoFilterChain.java:570)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
>    at
> org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput.flush(SimpleProtocolDecoderOutput.java:58)
>    at
> org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:180)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
>    at
> org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
>    at
> org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:220)
>    ... 5 more
>
> Any help would be much appreciated.
>
> Best regards,
> Nicolas.
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Reply via email to