You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by anandsk <sk...@arccorp.com> on 2010/03/02 17:10:05 UTC

Mina async route not working

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.


Re: Mina async route not working

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Mar 3, 2010 at 7:39 AM, Willem Jiang <wi...@gmail.com> wrote:
> Claus Ibsen wrote:
>>
>> On Wed, Mar 3, 2010 at 7:00 AM, anandsk <sk...@arccorp.com> 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.
>>>
>>
>> I think you need to split it into 2 routes then. One for sending, and
>> the other for listening for responses.
>>
>
> I just wandering, how can the two routes share the same Mina session ?

They can't, but it can be 2 request only message styles.

Otherwise he can always code it himself using the Mina API directly.

Or maybe look at Netty which is more in active development than Apache
Mina, which seems to newer get their act together and get 2.0 done.
It has been more than 2,5 years in development. Which makes me start
to loose faith in Mina.

Ashwin Karpe is working on a camel-netty component.





>
>>
>>
>>> 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 <sk...@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-tp27757690p27764563.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

Re: Mina async route not working

Posted by Willem Jiang <wi...@gmail.com>.
Claus Ibsen wrote:
> On Wed, Mar 3, 2010 at 7:00 AM, anandsk <sk...@arccorp.com> 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.
>>
> 
> I think you need to split it into 2 routes then. One for sending, and
> the other for listening for responses.
> 

I just wandering, how can the two routes share the same Mina session ?

> 
> 
>> 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 <sk...@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-tp27757690p27764563.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 


Re: Mina async route not working

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Mar 3, 2010 at 7:00 AM, anandsk <sk...@arccorp.com> 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.
>

I think you need to split it into 2 routes then. One for sending, and
the other for listening for responses.



> 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 <sk...@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-tp27757690p27764563.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

Re: Mina async route not working

Posted by anandsk <sk...@arccorp.com>.
that's a good idea. but external server vendor doesn't support this. would
there be any problems like loosing messages with iofilter approach
previously suggested or should I copy and customize Mina producer component
and change the messageReceiver method to send message to another endpoint
when it receives the message. 

                from("file:///test/test/response") 
                .convertBodyTo(String.class).threads(1) 
               
.to("custommina:tcp://localhost:6202?sync=false&textline=true"); 
                
                from("vm:response") 
                .to("log:+++ reply++++"); 

snippet from class ResponseHandler 

    @Produce(uri = "vm:response") 
    ProducerTemplate producer;       
  @Override 
        public void messageReceived(IoSession ioSession, Object message)
throws Exception { 
                producer.sendBody(message); 

Ashwin Karpe wrote:
> 
> Hi,
> 
> Is it not possible for you to decouple request-response communication with
> your server using one way invocations and use a correlationId to correlate
> the server responses at a later point i.e.
> 
> 1> Client sends a one way invocation to the server on a port XXX and
> optionally (sends a replyTo socket address in the payload)
>   client:      
>         from("file:///test/test/response")
>                 .setHeader("replyToAddress, constant("XXX");
> 		.to("mina:tcp://localhost:6202?sync=false");
> 
> 2> At a some later point the server responds to the replyToAddress with a
> response that is correlated using some correlationId in the data
>   server:     
>        from("mina:tcp://localhost:6202?sync=false")
>               .process(new Processor() {
>                      // ... process payload and get replyToAddress
>                      ...
>                      // sleep fo 20 seconds
>                      sleep(20000)
> 
>                      // Send response to client
>                      ProducerTemplate template = new ProducerTemplate();
>                      template.sendBody("XXX", response);                    
>               });
> 
> Hope this helps.
> 
> Cheers,
> 
> Ashwin
> 
> anandsk wrote:
>> 
>> 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 <sk...@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-tp27757690p28191049.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Mina async route not working

Posted by anandsk <sk...@arccorp.com>.
this looks like a good idea but external server vendor doesn't support this.
would there be any problems like loosing messages with iofilter approach
previously suggested or should I copy and customize Mina producer component
and change the messageReceiver method to send message to another endpoint
when it receives the message.

		from("file:///test/test/response")
		.convertBodyTo(String.class).threads(1)
		.to("custommina:tcp://localhost:6202?sync=false&textline=true");
		
		from("vm:response")
		.to("log:+++ reply++++"); 

snippet from class ResponseHandler 

    @Produce(uri = "vm:response")
    ProducerTemplate producer;      
  @Override
        public void messageReceived(IoSession ioSession, Object message)
throws Exception {
	        	producer.sendBody(message);
 



Ashwin Karpe wrote:
> 
> Hi,
> 
> Is it not possible for you to decouple request-response communication with
> your server using one way invocations and use a correlationId to correlate
> the server responses at a later point i.e.
> 
> 1> Client sends a one way invocation to the server on a port XXX and
> optionally (sends a replyTo socket address in the payload)
>   client:      
>         from("file:///test/test/response")
>                 .setHeader("replyToAddress, constant("XXX");
> 		.to("mina:tcp://localhost:6202?sync=false");
> 
> 2> At a some later point the server responds to the replyToAddress with a
> response that is correlated using some correlationId in the data
>   server:     
>        from("mina:tcp://localhost:6202?sync=false")
>               .process(new Processor() {
>                      // ... process payload and get replyToAddress
>                      ...
>                      // sleep fo 20 seconds
>                      sleep(20000)
> 
>                      // Send response to client
>                      ProducerTemplate template = new ProducerTemplate();
>                      template.sendBody("XXX", response);                    
>               });
> 
> Hope this helps.
> 
> Cheers,
> 
> Ashwin
> 
> anandsk wrote:
>> 
>> 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 <sk...@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-tp27757690p28190841.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Mina async route not working

Posted by Ashwin Karpe <as...@progress.com>.
Hi,

Is it not possible for you to decouple request-response communication with
your server using one way invocations and use a correlationId to correlate
the server responses at a later point i.e.

1> Client sends a one way invocation to the server on a port XXX and
optionally (sends a replyTo socket address in the payload)
  client:      
        from("file:///test/test/response")
                .setHeader("replyToAddress, constant("XXX");
		.to("mina:tcp://localhost:6202?sync=false");

2> At a some later point the server responds to the replyToAddress with a
response that is correlated using some correlationId in the data
  server:     
       from("mina:tcp://localhost:6202?sync=false")
              .process(new Processor() {
                     // ... process payload and get replyToAddress
                     ...
                     // sleep fo 20 seconds
                     sleep(20000)

                     // Send response to client
                     ProducerTemplate template = new ProducerTemplate();
                     template.sendBody("XXX", response);                    
              });

Hope this helps.

Cheers,

Ashwin

anandsk wrote:
> 
> 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 <sk...@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
>>>>>>>
>>>>>>>
>>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: http://old.nabble.com/Mina-async-route-not-working-tp27757690p27779803.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Mina async route not working

Posted by anandsk <sk...@arccorp.com>.
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 <sk...@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.


Re: Mina async route not working

Posted by anandsk <sk...@arccorp.com>.
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 <sk...@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-tp27757690p27771972.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Mina async route not working

Posted by Ashwin Karpe <as...@progress.com>.
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 <sk...@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
>>>>
>>>>
>>> 
>> 
>> 
>> 
> 
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: http://old.nabble.com/Mina-async-route-not-working-tp27757690p27768427.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Mina async route not working

Posted by anandsk <sk...@arccorp.com>.
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 <sk...@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-tp27757690p27764563.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Mina async route not working

Posted by Willem Jiang <wi...@gmail.com>.
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 <sk...@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
>>
>>
> 


Re: Mina async route not working

Posted by anandsk <sk...@arccorp.com>.
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 <sk...@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-tp27757690p27762540.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Mina async route not working

Posted by Claus Ibsen <cl...@gmail.com>.
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 <sk...@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