camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" <claus.ib...@gmail.com>
Subject Re: camel-mina in servicemix - how to process TCP response?
Date Wed, 03 Dec 2008 08:45:34 GMT
On Wed, Dec 3, 2008 at 9:37 AM, Suraf <rafal.suchocki@sabre.com> wrote:
>
> Hi,
>
> #1: TCP server expects plain XML so I removed transferExchange=true option.
> Thanks for that.
>
>
> #2: My In message from 2nd processor looks like a sum of In message from 1st
> processor and Out message (which is a processed In message) from 1st
> processor. So it looks like in below example:
>
> Processor I - In message: <AAA><BBB/></AAA>
> Processor I - Out message (after processing In message):
> <AAA><BBB><CCC/></BBB></AAA>
> Processor II - In message: <AAA><BBB/></AAA><AAA><BBB><CCC/></BBB></AAA>
> Processor II - Out message: null
>
> Maybe I'm wrong but it doesn't seem that Out from TCP is In for 2nd
> processor...
What is the OUT from the TCP? Maybe you can invoke the TCP directly
and see what it actually returns.

You could also try with a mock of the TCP server to return a fixed
response so you know what the OUT is and thus better can find out what
is wrong.



>
>
>
> I turned on tracing but it doesn't say anything more than
> java.lang.NullPointerException :(
Ah that could be the bug in Camel if a body is null. You need to turn
showBodyType=false to avoid this NPE:
http://activemq.apache.org/camel/tracer.html



>
> Any suggestions on that, please?
>
>
> Best regards,
> Suraf
>
>
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> #1
>> What format does the TCP server expect?
>> If it should be the exchange body as plain XML then you should not use
>> transferExchange=true.
>>
>>
>> #2
>> In the last processor could you try getting the IN body instead.
>> The processor is part of a new route where the OUT from the TCP server
>> is used as IN in the next node.
>>
>> BTW: You can use the tracer to see the messages being passed in the log
>> http://activemq.apache.org/camel/tracer.html
>>
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>>
>> On Tue, Dec 2, 2008 at 5:35 PM, Suraf <rafal.suchocki@sabre.com> wrote:
>>>
>>> All,
>>>
>>> I'm trying to execute a few steps using Camel-Mina TCP component in
>>> servicemix:
>>> - get InOut message from ServiceMix component
>>> - process message (processed message is still an XML)
>>> - send it to TCP server (via Mina)
>>> - get response from TCP server (response is an XML)
>>> - process response and send it back to ServiceMix component
>>>
>>> Here is my code:
>>>
>>> public class TcpRouteBuilder extends RouteBuilder {
>>>
>>>    public void configure() throws Exception {
>>>
>>>        String fullAddress = new StringBuilder()
>>>                .append("mina:tcp://")
>>>                .append(serverAddress)
>>>                .append(":")
>>>                .append(serverPort)
>>>
>>> .append("?textline=true&sync=true&transferExchange=true").toString();
>>>
>>>
>>> from("jbi:endpoint:http://namespace/tcpService/tcpEndpoint").process(
>>>                new Processor() {
>>>                    public void process(Exchange exchange) throws
>>> Exception
>>> {
>>>                        String xmlString = convertToString((DOMSource)
>>> exchange.getIn().getBody());
>>>                        xmlString = prepareMessage(xmlString);
>>>                        exchange.getIn().setBody(xmlString);
>>>                    }
>>>                }
>>>        ).to(fullAddress).process(
>>>                new Processor() {
>>>                    public void process(Exchange exchange) throws
>>> Exception
>>> {
>>>                        // here some additional processing of response is
>>> required but body seems to be null
>>>                        Object body = exchange.getOut().getBody();
>>>                        body = processBody( body );
>>>                        exchange.getOut().setBody(body);
>>>                    }
>>>                }
>>>        );
>>>    }
>>> }
>>>
>>> In the second processor I get null from exchange.getOut().getBody().
>>>
>>> What am I doing wrong? How should I get valid XML response from TCP and
>>> process it somehow?
>>> Could you please advice something?
>>>
>>> I'm using FuseESB 3.3.1.11 with Camel 1.5.0 (camel-core-1.5.0.0-fuse.jar
>>> and
>>> camel-mina-1.5.0.jar) and Mina 1.1.7 (mina-core-1.1.7.jar).
>>>
>>> Thanks in advance for your help.
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/camel-mina-in-servicemix---how-to-process-TCP-response--tp20794416s22882p20794416.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/camel-mina-in-servicemix---how-to-process-TCP-response--tp20794416s22882p20808827.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Mime
View raw message