6 Replies Latest reply on Sep 21, 2010 5:21 AM by mariateresa

    hornetq netty

    mariateresa

      Hi,

       

      I'm pretty new to hornetq, and I'm having a little trouble implementing a solution that I believe hornet with netty can handle.

      Hornetq's team says "is an open source project to build a multi-protocol, embeddable, very high performance, clustered, asynchronous messaging system."

      I had a problem where a socket client needed to connect to a JEE server.
      I've done this before with a simple listener and starting threads in the server but I wanted to follow a standards oriented approach for a new development.
      What I have to do is an application in which a client will send messages to a server over a single non blocking socket connection via TCP/IP.
      The message is a custom protocol message with a fixed length.

       

      The entire application should be deployed on an application server, preferably Jboss, but
      J2EE  forbids components from explicit thread management. The application server should manage threads exclusively.
      So, I thought to use a JCA resource adapter that accepts simple TCP/IP socket connections from clients.
      Is there a way to integrate a connector with hornetq into jboss for example or is there a better way to solve this scenario?

      I think I need something different that jms, is possible with hornetq listening over a socket inside an application server?

       

      Any help/suggestions would be greatly appreciated!

       

      Thank you

        • 1. Re: hornetq netty
          timfox

          I'm not sure what you're trying to do here, but it sounds like you want to create your own client?

           

          If so, why don't you just use the HornetQ client? It would be a lot easier.

          • 2. Re: hornetq netty
            mariateresa

            What I have to do is develop a server component deployed into an application server that accepts simple TCP/IP socket connections from clients.

            This clients need to connect to a JEE server, they have to do with legacy clients and cannot be changed.


            I've done this before with a simple listener and starting threads (server socket) in the server but I wanted to follow a standards oriented approach for a new development.

             

            So I decided to use a JCA resource adapter to solve this scenario.

            Java Connector Architecture 1.5 and EJB  Message Driven Beans combine to allow new server components to be deployed within application servers in a portable and standardized way.

            With JCA developers are able to extend the services offered by the application server to any protocol or technology and the application server is truly extensible.

            (See http://www.theserverside.com/news/1364656/Serve-It-Up-with-J2EE-14-Use-JCA-15-and-EJB-21-to-Extend-your-App-Server for more details).

             

            Then when I saw hornetq's documentation I thought that it would helps me simplify matters.

            I thounght that hornetq acceptor could listens over an IP and port, and it could receive tcp message through netty.

             

            Do you get my point?

            I can say more if you need

            Thanks in advance and sorry for my english.

            • 3. Re: hornetq netty
              timfox

              I don't really see how this relates to a messaging system like HornetQ.

              • 4. Re: hornetq netty
                mariateresa

                Ok, so if hornetq cannot help me to accept socket message, it could help me to control the message flow once it's arrived on the server.

                So, once I have my custom message on a MDB as shown below

                 

                 

                public interface LtmTerminalMessageListener {
                void onMessage(LtmTerminalMessage msg);
                }

                ______________________________________________

                public interface MyMessageListener {

                 

                void onMessage(MyMessage msg);

                }______________________________________________

                 

                 

                public interface MyMessage {

                 

                InetSocketAddress getInetSocketAddress();

                 

                ByteBuffer getInputData();

                 

                void setOutputData(ByteBuffer[] byteBuffer);

                 

                long getReceivedTime();

                }______________________________________________

                 

                 

                 

                public class TisMDB implements MessageDrivenBean, LtmTerminalMessageListener {

                ...

                 

                 

                public void onMessage(MyMessage msg) {

                log.info("Got MyMessage: " + msg);

                 

                                byte[] temp1 = getInputPacket(msg.getInputData().array());

                 

                 

                //PUBLISH THE MESSAGE TO RELATIVE ADDRESS AFTER READING HEADER

                ByteBuffer bb = ByteBuffer.wrap(temp1);

                msg.setOutputData(new ByteBuffer[] { bb });

                 

                 

                }

                ...

                ______________________________________________

                 

                I could divert and split message for example based on his header.

                I have a sequence of services that I have to call if some flags are present on the header (e.g. gzip, crypting ..) , so I have to divert messages.

                I must handle many thousand of messages per second.

                 

                Thanks.

                • 5. Re: hornetq netty
                  ataylor

                  Ok,

                   

                  so if this is what you want to do you need to write your own JCA adaptor, this does not really have anything to do with HornetQ you should read the JCA spec (good luck) and read the JCA forums on how best to implement this. what you do in your JCA adaptor when you read your data from the buffer is up to you, you could wrap it up in a JMS and forward it to an endpoint(mdb) or something else, this is up to you. You could look at the HornetQ RA for some hints and tips and tp see what API to implement but like Tim says, its not really a problem that can be solved withHornetQ.

                   

                  good luck

                  • 6. Re: hornetq netty
                    mariateresa

                    I had already implemented my JCA resource adaptor to solve this scenario, as above.

                    What I would to know now is if the idea of handle the message flow with hornetq is good or not for my use case, after messages arrived on MDB.

                     

                    public void onMessage(MyMessage msg) {

                    log.info("Got MyMessage: " + msg);

                     

                                    byte[] temp1 = getInputPacket(msg.getInputData().array());

                    //PUBLISH THE MESSAGE TO RELATIVE ADDRESS AFTER READING HEADER

                    ByteBuffer bb = ByteBuffer.wrap(temp1);

                    msg.setOutputData(new ByteBuffer[] { bb });

                     

                     

                    }

                     

                    At the beginning the concept of acceptor combined with netty was not so clear for me, I thought that the use of acceptors could help me to comunicate with TCP socket client.

                    Now is clear.

                    Thanks.