it seems to work when I use iofilter, but I am not sure when this producer going to be destroyed, if it gets desroyed before it receives a reply then I will loose message, I feel that this may not be a right solution.
from("file:///test/test/response") .convertBodyTo(String.class).threads(1) .to("mina:tcp://localhost:6202?sync=false&textline=true&filters=#listFilters"); from("vm:response") .to("log:+++ reply++++"); public class MessageFilter extends IoFilterAdapter { @Produce(uri = "vm:response") ProducerTemplate producer; @Override public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception { if (message instanceof String) { producer.sendBody(message); } nextFilter.messageReceived(session, message); } } anandsk wrote: > > Ashwin, > > it is a simulated consumer in my code with a delay, actual consumer is a > external system which could take some time to send reply. > > I am using "toasync" instead of "to" so that I don't loose message. are > we saying that option sync=false doesn't work in combination with > "toasync"?. > > Thanks for working on a new framework. I am using this for a production > app, so I don't have much time to wait and switch to a new tcp > frameworks. > > Thanks, > Anand > > Ashwin Karpe wrote: >> >> Hi, >> >> Anand, it seems like you have sync set to true for the consumer, thereby >> making it a In-Out exchange driven consumer (i.e request/response). >> >> However your producer is set with sync=false thereby making it an >> in-only. This will cause the response to fall through the cracks and >> cause connection closure on the consumer. This should hopefully fix it >> for you. >> >> BTW, as Claus mentioned, I am working on a Camel Netty component (coding >> is done, currently writing tests and adding SSL support). I will bring it >> to the community in the next 2-3 weeks after due testing and cleanup. >> >> Cheers, >> >> Ashwin... >> >> >> anandsk wrote: >>> >>> Hi, Thanks for the response. I can use only one thread for sending >>> messages becuase I can have only one TCP connection to external server. >>> if I change sync flag to true then that thread is going to wait till the >>> response comes back before it sends another message right?. I want to be >>> able to send multiple requests one after the other without waiting for a >>> response. responses need to be processed asynchronously.So, I can't set >>> sync flag to true, is there any other solution to my problem. >>> >>> Thanks, >>> Anand >>> >>> willem.jiang wrote: >>>> >>>> Hi I think you need to change the route like this >>>> >>>> from("mina:tcp://localhost:6202?textline=true&sync=true").process(new >>>> Processor() { >>>> public void process(Exchange exchange) throws Exception { >>>> String body = exchange.getIn().getBody(String.class); >>>> Thread.sleep(30000); >>>> exchange.getOut().setBody("Bye 1" + body); >>>> } >>>> }); >>>> >>>> from("file:///test/test/response") >>>> .convertBodyTo(String.class) >>>> .toAsync("mina:tcp://localhost:6202?sync=true&textline=true",10) >>>> .to("log:+++ reply++++"); >>>> To make sure the mina client can get the right response. >>>> >>>> Willem >>>> >>>> anandsk wrote: >>>>> Thanks. yes, I have seen the examples and I modified my code. but it >>>>> still >>>>> doesn't deliver reply asyncronously. >>>>> I am thinking may be camel Mina's sync option may be conflicting with >>>>> async >>>>> route. Please see my code below. >>>>> >>>>> >>>>> from("mina:tcp://localhost:6202?textline=true&sync=true").process(new >>>>> Processor() { >>>>> public void process(Exchange exchange) throws Exception { >>>>> String body = exchange.getIn().getBody(String.class); >>>>> Thread.sleep(30000); >>>>> exchange.getOut().setBody("Bye 1" + body); >>>>> } >>>>> }); >>>>> >>>>> from("file:///test/test/response") >>>>> .convertBodyTo(String.class) >>>>> >>>>> .toAsync("mina:tcp://localhost:6202?sync=false&textline=true",10) >>>>> .to("log:+++ reply++++"); >>>>> >>>>> >>>>> >>>>> Claus Ibsen-2 wrote: >>>>>> Have you seen the 2 asyncTo examples which are listed here? >>>>>> http://camel.apache.org/examples.html >>>>>> >>>>>> >>>>>> >>>>>> On Tue, Mar 2, 2010 at 5:10 PM, anandsk <sku...@arccorp.com> wrote: >>>>>>> Hi, >>>>>>> I tried this route with camel 2.2 and it is not forwarding response >>>>>>> to >>>>>>> end >>>>>>> point defined in async "direct:response". also I see the logs >>>>>>> showing >>>>>>> that >>>>>>> mina producer receiving the message back from tcp server but it is >>>>>>> not >>>>>>> forwarding them to async endpoint. am I doing this wrong. >>>>>>> >>>>>>> Thanks, >>>>>>> Anand >>>>>>> >>>>>>> >>>>>>> from("mina:tcp://localhost:6202?textline=true&sync=true").process(new >>>>>>> Processor() { >>>>>>> public void process(Exchange exchange) throws >>>>>>> Exception { >>>>>>> String body = >>>>>>> exchange.getIn().getBody(String.class); >>>>>>> //Thread.currentThread(); >>>>>>> Thread.sleep(1000); >>>>>>> exchange.getOut().setBody("Bye 1" + >>>>>>> body+"\n"); >>>>>>> //exchange.getOut().setBody("Bye 2" + >>>>>>> body+"\n"); >>>>>>> } >>>>>>> }); >>>>>>> >>>>>>> >>>>>>> //from("jms:test.Camel1") >>>>>>> from("file:///test/test/response") >>>>>>> .convertBodyTo(String.class).threads(1) >>>>>>> //.to("log:jms.queue.message") >>>>>>> //.bean(smooks.StatusRequestMessageHandler.class) >>>>>>> //.setHeader(MinaEndpoint.HEADER_MINA_IOSESSION, >>>>>>> expression) >>>>>>> >>>>>>> .to("mina:tcp://localhost:6202?textline=true&sync=true") >>>>>>> .toAsync("direct:response",1) >>>>>>> .to("log:direct"); >>>>>>> >>>>>>> from("direct:response") >>>>>>> .to("log:jms.queue.message"); >>>>>>> -- >>>>>>> View this message in context: >>>>>>> http://old.nabble.com/Mina-async-route-not-working-tp27757690p27757690.html >>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com. >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Claus Ibsen >>>>>> Apache Camel Committer >>>>>> >>>>>> Author of Camel in Action: http://www.manning.com/ibsen/ >>>>>> Open Source Integration: http://fusesource.com >>>>>> Blog: http://davsclaus.blogspot.com/ >>>>>> Twitter: http://twitter.com/davsclaus >>>>>> >>>>>> >>>>> >>>> >>>> >>>> >>> >>> >> >> > > -- View this message in context: http://old.nabble.com/Mina-async-route-not-working-tp27757690p27773119.html Sent from the Camel - Users mailing list archive at Nabble.com.