Receiving over IP and port using TCP

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Receiving over IP and port using TCP

earthonclouds
This post has NOT been accepted by the mailing list yet.
Hi

This question must have been asked before but I could not find the right solution.

I wanted to post a String to the default TCP port but I am getting different kinds of exception.
Exception
jvm 1    |  WARN | Transport Connection to: tcp://127.0.0.1:57005 failed: java.i
o.IOException: Frame size of 1158 MB larger than max allowed 100 MB

whereas the activemq.xml has the following line.

            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;textline=true&amp;wireFormat.maxFrameSize=104857600"/>


and the piece of code that I am running to send the data is as follows:
        public static void main(String argv[]) throws Exception
        {
                      try
                      {
                         Socket client = new Socket("localhost", 61616);
                         OutputStream outToServer = client.getOutputStream();
                         DataOutputStream out = new DataOutputStream(outToServer);
                         DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
                  Date todayDate = new Date();
                  String abc="Hello World";
                  byte[] b = abc.getBytes();
                     out.write(b);//(" Content gets received in server");
                         
                         client.close();
                      }catch(IOException e)
                      {
                         e.printStackTrace();
                      }
        }


Can someone help please. What am I missing?
I am sending it over TCP/sockets as I understand
Reply | Threaded
Open this post in threaded view
|

Re: Receiving over IP and port using TCP

artnaseef
That code is trying to communicate with the broker without using the broker's protocol (openwire).  So, the broker is really complaining that it cannot properly parse the content.

The correct way to use TCP/IP to connect to the broker is to create an ActiveMQConnectionFactory() using the tcp transport (like this for localhost: tcp://localhost:61616), and then use the ActiveMQConnection to create a session and producer, then send a message.
Reply | Threaded
Open this post in threaded view
|

Re: Receiving over IP and port using TCP

earthonclouds
Thanks for the reply. I understood that in order to pass the data over TCP I need to follow ActiveMQConnectionFactory classes.

But my concern is, like when we do a socket programming, we connect to a port and push the data. The server code listens on the same port and reads the data as it comes.

I want to do the same thing, where I want to push my content from a m2m device. The device sends data over TCP to a particular port. e.g. <ā€™Cā€™><0x02><data 1><data 2>

Can we not read a particular socket/port and feed to Activemq?

Regards
Saurabh
Reply | Threaded
Open this post in threaded view
|

Re: Receiving over IP and port using TCP

artnaseef
If you want a "raw TCP/IP" connection, then it needs some type of protocol - even if home-grown.

Perhaps you could use Camel's Mina connector to implement what you want.  Otherwise, you'll likely want a service that interfaces between the m2m devices and ActiveMQ.  The latter is the path I would seriously consider unless this is just for a test environment, prototype, or something else that does not need to be production-grade.

If you can get a STOMP client to run on the m2m device, perhaps that's a good alternative.

Actually, back to the original concern, is there a reason the m2m device cannot use an ActiveMQ connection?
Reply | Threaded
Open this post in threaded view
|

Re: Receiving over IP and port using TCP

uromahn
CONTENTS DELETED
The author has deleted this message.