camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <>
Subject Re: async requests and responses on a single connection
Date Thu, 01 Apr 2010 05:42:57 GMT
I don't think current mina producer can do the work that you want.
But if you take a look at the Camel 2.x Async[1], and 
JettyHttpProduer[2], you can find a way to implement the async request 
and response with Camel.



anandsk wrote:
> Thanks for response,I beleive it's same behavior in camel mina 2.0 and 2.2.
> we are thinking of using 2.0M2 as we have release in a month. But my main
> question is how do I keep this producer object/component alive till a route
> is shutdown so that I don't loose any messages. any thoughts on solution
> below, i know it is not elegant as I am using filter to capture the replies
> from external server but would there be a possibility of loosing messages
> with this approach?. 
> also what is the life cycle of a producer/component?.
> willem.jiang wrote:
>> I think you can let the producer keep the connection.
>> I just checked the code of camel-mina, the mina producer only close the 
>> session if the disconnect option[1] is true (it is new for camel 2.3.0).
>> So please try out the latest Camel 2.3.0-SNAPSHOT for verification.
>> [1]
>> Willem
>> anandsk wrote:
>>> can I make the producer object to stay around and keep it connected to
>>> external address until a route is shutdown that way we can gurantee no
>>> loss
>>> of message?.any thoughts?.
>>> anandsk wrote:
>>>> Sorry this may be a repost. I was wondering if anyone has solved this. I
>>>> can use only one thread for sending messages becuase I can have only
>>>> single TCP connection to external server. I want to be able to send
>>>> multiple requests one after the other without waiting for a response.
>>>> responses need to be processed asynchronously. any solutions for this
>>>> scenario?. 
>>>> Here is one possible solution but I am not sure about the life cycle of
>>>> the mina endpoint, is it possible to loose messages with this solution?.
>>>> I
>>>> have also written custom component to share same endpoint/receivehandler
>>>> for the producer and consumer. I would like to use below solution or
>>>> variation of it  if there are no problems with it. as you can see below
>>>> solution is very simple compared to writing a custom component.
>>>> also I want to findout if 2.3 or later releases have plans to include a
>>>> component for the typical requirement defined above.
>>>>                 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); 
>>>>             } 
>>>> } 

View raw message