You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Saurabh Singhal <ea...@gmail.com> on 2014/12/09 10:33:32 UTC

Apache Camel Mina2 not receiving data using Socket

I have been trying to send data through socket programming to Apache Camel
and I am trying to use *Apache Mina2*. The idea is to send the data over TCP
to Camel. For TCP, I am using socket programing. This is what my code is for
*Mina2*:

public void configure() throws Exception {
from("mina2:tcp://localhost:6789?sync=false&")
    .process(new LogProcessor());
}

*LogProcessor *only prints the body of the received message using :
*exchange.getIn().getBody(String.class)*

This piece of code works fine with Apache Mina as below:

*from("mina:tcp://localhost:6789?textline=true&sync=true")
    .process(new LogProcessor());*

The socket programming client code that I am using is as below:

  try
      {
         Socket client = new Socket();


         PrintWriter s_out = null;*/

         client.connect(new InetSocketAddress("localhost", 6789));

         OutputStream outToServer = client.getOutputStream();
         DataOutputStream out = new DataOutputStream(outToServer);
         System.out.println("After Dataoutput stream");
         out.writeBytes("Content gets received in server\n");

         client.close();
      }
The same piece of code works fine for Mina but does not work with Mina2. I
am unable to figure out what is causing the problem. Do I need to add some
parameters in the from clause of Camel.

Kindly help.



--
View this message in context: http://camel.465427.n5.nabble.com/Apache-Camel-Mina2-not-receiving-data-using-Socket-tp5760372.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Apache Camel Mina2 not receiving data using Socket

Posted by Thomas Termin <th...@gmail.com>.
Hi,

tried it also with your Socket Client and works als fine.

Thomas

On Thu, Dec 11, 2014 at 10:20 AM, Thomas Termin <th...@gmail.com>
wrote:

> Hi,
>
> just tried the example route builder with mina2 (camel-2.14.0) and it
> works fine using telnet as client.
>
> telnet localhost 6789
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> hallo
> Bye hallo
> Connection closed by foreign host.
>
> Which camel version do you use? Can you provide something useful from
> within the logs?
>
> Thomas
>
>
> On Wed, Dec 10, 2014 at 8:05 PM, Saurabh Singhal <ea...@gmail.com>
> wrote:
>
>> Hi
>>
>> Thanks for the reply. Basically when I send the data using a socket
>> programming code as mentioned in the problem, it does not print the
>> output.
>> I even copied the from to code from Apache camel site as below:
>>
>>
>> from("mina2:tcp://localhost:6789?sync=true&textline=true").process(new
>> Processor() {
>>                     public void process(Exchange exchange) throws
>> Exception {
>>                         String body =
>> exchange.getIn().getBody(String.class);
>>                         exchange.getOut().setBody("Bye " + body);
>>
>>
>> exchange.getOut().setHeader(Mina2Constants.MINA_CLOSE_SESSION_WHEN_COMPLETE,
>> true);
>>                     }
>>                 });
>>
>> I have seen a couple of posts which says that there are issues with camel
>> netty4 regarding session etc. Moreover my code is working with mina and
>> not
>> mina2 .. surprising !!
>>
>> Any help would be appreciated. Thanks in advance
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Apache-Camel-Mina2-not-receiving-data-using-Socket-tp5760372p5760518.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>

Re: Apache Camel Mina2 not receiving data using Socket

Posted by Thomas Termin <th...@gmail.com>.
Hi,

just tried the example route builder with mina2 (camel-2.14.0) and it works
fine using telnet as client.

telnet localhost 6789
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
hallo
Bye hallo
Connection closed by foreign host.

Which camel version do you use? Can you provide something useful from
within the logs?

Thomas


On Wed, Dec 10, 2014 at 8:05 PM, Saurabh Singhal <ea...@gmail.com>
wrote:

> Hi
>
> Thanks for the reply. Basically when I send the data using a socket
> programming code as mentioned in the problem, it does not print the output.
> I even copied the from to code from Apache camel site as below:
>
>
> from("mina2:tcp://localhost:6789?sync=true&textline=true").process(new
> Processor() {
>                     public void process(Exchange exchange) throws
> Exception {
>                         String body =
> exchange.getIn().getBody(String.class);
>                         exchange.getOut().setBody("Bye " + body);
>
>
> exchange.getOut().setHeader(Mina2Constants.MINA_CLOSE_SESSION_WHEN_COMPLETE,
> true);
>                     }
>                 });
>
> I have seen a couple of posts which says that there are issues with camel
> netty4 regarding session etc. Moreover my code is working with mina and not
> mina2 .. surprising !!
>
> Any help would be appreciated. Thanks in advance
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Apache-Camel-Mina2-not-receiving-data-using-Socket-tp5760372p5760518.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Apache Camel Mina2 not receiving data using Socket

Posted by Saurabh Singhal <ea...@gmail.com>.
Hi

Thanks for the reply. Basically when I send the data using a socket
programming code as mentioned in the problem, it does not print the output.
I even copied the from to code from Apache camel site as below: 

		from("mina2:tcp://localhost:6789?sync=true&textline=true").process(new
Processor() {
		    public void process(Exchange exchange) throws Exception {
		        String body = exchange.getIn().getBody(String.class);
		        exchange.getOut().setBody("Bye " + body);
		       
exchange.getOut().setHeader(Mina2Constants.MINA_CLOSE_SESSION_WHEN_COMPLETE,
true);
		    }
		});

I have seen a couple of posts which says that there are issues with camel
netty4 regarding session etc. Moreover my code is working with mina and not
mina2 .. surprising !!

Any help would be appreciated. Thanks in advance



--
View this message in context: http://camel.465427.n5.nabble.com/Apache-Camel-Mina2-not-receiving-data-using-Socket-tp5760372p5760518.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Apache Camel Mina2 not receiving data using Socket

Posted by Thomas Termin <th...@gmail.com>.
Hello,

my answer was a bit confussing maybe. The first sentence is realted to your
sync=false which will not work in camel-mina2.
Btw. you should give camel-netty4 a try.

Thomas

On Wed, Dec 10, 2014 at 9:34 AM, Thomas Termin <th...@gmail.com>
wrote:

> Hello,
>
> Since camel-mina2 all consumer(from) exchanges are InOut. This is
> different to camel-mina. Maybe it is related to that one.
> But actually you say just it does not work. But what exactly is not
> working?
>
> Thomas
>
> On Tue, Dec 9, 2014 at 10:33 AM, Saurabh Singhal <ea...@gmail.com>
> wrote:
>
>> I have been trying to send data through socket programming to Apache Camel
>> and I am trying to use *Apache Mina2*. The idea is to send the data over
>> TCP
>> to Camel. For TCP, I am using socket programing. This is what my code is
>> for
>> *Mina2*:
>>
>> public void configure() throws Exception {
>> from("mina2:tcp://localhost:6789?sync=false&")
>>     .process(new LogProcessor());
>> }
>>
>> *LogProcessor *only prints the body of the received message using :
>> *exchange.getIn().getBody(String.class)*
>>
>> This piece of code works fine with Apache Mina as below:
>>
>> *from("mina:tcp://localhost:6789?textline=true&sync=true")
>>     .process(new LogProcessor());*
>>
>> The socket programming client code that I am using is as below:
>>
>>   try
>>       {
>>          Socket client = new Socket();
>>
>>
>>          PrintWriter s_out = null;*/
>>
>>          client.connect(new InetSocketAddress("localhost", 6789));
>>
>>          OutputStream outToServer = client.getOutputStream();
>>          DataOutputStream out = new DataOutputStream(outToServer);
>>          System.out.println("After Dataoutput stream");
>>          out.writeBytes("Content gets received in server\n");
>>
>>          client.close();
>>       }
>> The same piece of code works fine for Mina but does not work with Mina2. I
>> am unable to figure out what is causing the problem. Do I need to add some
>> parameters in the from clause of Camel.
>>
>> Kindly help.
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Apache-Camel-Mina2-not-receiving-data-using-Socket-tp5760372.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>

Re: Apache Camel Mina2 not receiving data using Socket

Posted by Thomas Termin <th...@gmail.com>.
Hello,

Since camel-mina2 all consumer(from) exchanges are InOut. This is different
to camel-mina. Maybe it is related to that one.
But actually you say just it does not work. But what exactly is not working?

Thomas

On Tue, Dec 9, 2014 at 10:33 AM, Saurabh Singhal <ea...@gmail.com>
wrote:

> I have been trying to send data through socket programming to Apache Camel
> and I am trying to use *Apache Mina2*. The idea is to send the data over
> TCP
> to Camel. For TCP, I am using socket programing. This is what my code is
> for
> *Mina2*:
>
> public void configure() throws Exception {
> from("mina2:tcp://localhost:6789?sync=false&")
>     .process(new LogProcessor());
> }
>
> *LogProcessor *only prints the body of the received message using :
> *exchange.getIn().getBody(String.class)*
>
> This piece of code works fine with Apache Mina as below:
>
> *from("mina:tcp://localhost:6789?textline=true&sync=true")
>     .process(new LogProcessor());*
>
> The socket programming client code that I am using is as below:
>
>   try
>       {
>          Socket client = new Socket();
>
>
>          PrintWriter s_out = null;*/
>
>          client.connect(new InetSocketAddress("localhost", 6789));
>
>          OutputStream outToServer = client.getOutputStream();
>          DataOutputStream out = new DataOutputStream(outToServer);
>          System.out.println("After Dataoutput stream");
>          out.writeBytes("Content gets received in server\n");
>
>          client.close();
>       }
> The same piece of code works fine for Mina but does not work with Mina2. I
> am unable to figure out what is causing the problem. Do I need to add some
> parameters in the from clause of Camel.
>
> Kindly help.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Apache-Camel-Mina2-not-receiving-data-using-Socket-tp5760372.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>