You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Nicky Sandhu <ni...@hotmail.com> on 2007/08/24 19:06:43 UTC

Request response with a tcp socket

Use case of sending a message to a tcp port and reading the response. I tried
this...maybe i am missing the point

from("direct:a").to("mina:tcp://someserver:someport").to("direct:b")

The expectation was to be able to create a producer on "direct:a" endpoint
and consume an exchange with an in body = request message. Then assert that
on "direct:b" end point it would receive an exchange with an outbody of the
response.

Instead I believe the component does something similar to http component and
tries to host the socket in camel. 

I can envision writing a component to do the above but I am not sure I want
to duplicate existing functionality
-- 
View this message in context: http://www.nabble.com/Request-response-with-a-tcp-socket-tf4324671s22882.html#a12316233
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Request response with a tcp socket

Posted by davsclaus <ci...@yahoo.dk>.
Nicky

Did you ever get a response or figured it out how to work with
request/response using TCP in Camel?

I am also trying to build a small sample that:
1. accepts incoming requests from TCP
2. processes the exchange
3. returns a response to step #1 at the TCP

However I haven't figured it out how to do IN/OUT with the Mina component.
       from("mina:tcp://localhost:8888?textline=true").process(new
MyProcessor());

doesn't return a response when I do the following test:

        CamelTemplate template = new CamelTemplate(context);
        context.start();

        String response = (String)
template.requestBody("mina:tcp://localhost:8888", "Hello Claus");
        System.out.println("Response is " + response);


I get this exception instead:

Exception in thread "main" org.apache.camel.RuntimeCamelException:
java.lang.RuntimeException: No response from server within 10000 millisecs
	at org.apache.camel.util.ProducerCache.send(ProducerCache.java:134)
	at org.apache.camel.CamelTemplate.send(CamelTemplate.java:144)
	at org.apache.camel.CamelTemplate.sendBody(CamelTemplate.java:158)
	at org.apache.camel.CamelTemplate.sendBody(CamelTemplate.java:197)
	at org.apache.camel.CamelTemplate.requestBody(CamelTemplate.java:353)
	at dk.claus.camel.CamelFun.main(CamelFun.java:23)





Nicky Sandhu wrote:
> 
> Use case of sending a message to a tcp port and reading the response. I
> tried this...maybe i am missing the point
> 
> from("direct:a").to("mina:tcp://someserver:someport").to("direct:b")
> 
> The expectation was to be able to create a producer on "direct:a" endpoint
> and consume an exchange with an in body = request message. Then assert
> that on "direct:b" end point it would receive an exchange with an outbody
> of the response.
> 
> Instead I believe the component does something similar to http component
> and tries to host the socket in camel. 
> 
> I can envision writing a component to do the above but I am not sure I
> want to duplicate existing functionality
> 

-- 
View this message in context: http://www.nabble.com/Request-response-with-a-tcp-socket-tp12316233s22882p15395568.html
Sent from the Camel - Users mailing list archive at Nabble.com.