12 Replies Latest reply on Mar 12, 2012 4:03 AM by davsclaus

    Simple Camel-Netty Examples/Issue?

    dr8ball

      Is there any good examples using the camel-netty component?  We have a project in which we want to route some XML messages from a TCP connection to a JMS topic vice versa.  At first I thought that camel-netty or camel-mina would be perfect for this. After some research it appeared that camel-netty is preferred over camel-mina so I started with a simple example.  I currently have a timer feeding messages to a topic which is then sent out via netty, unfortunately it appears that only the first message is received by the server.  Any ideas?

       

       

      from("activemq:topic:topic.tcp.1.out")

          .to("netty:tcp://localhost:4444?textline=true&sync=false");

        • 1. Re: Simple Camel-Netty Examples/Issue?
          davsclaus

          Are you sure the receiver is using the same codec as you? eg you specify textline, which means its a text based codec, that terminates with a newline.

           

          You can add a .to("log:from-topic") in the route, so you can see in the log that you receive more messages from the topic.

          • 2. Re: Simple Camel-Netty Examples/Issue?
            davsclaus

            Also you may want to use the old camel-mina component, until this bug is fixed in camel-netty: https://issues.apache.org/jira/browse/CAMEL-4556

            • 3. Re: Simple Camel-Netty Examples/Issue?
              dr8ball

              Thanks for the quick reply Claus.  I have been enjoying your book "Camel in Action" and am looking forward to using FUSE.  I have tinkered with Camel and FUSE ESB before but this is my first time to get to use it for one of our projects.  If we can get this to work then my hope is that we will use it more. 

               

              The short answer is no, they are not using the same "codec", and yes multiple messages are being sent to my topic destination.  My test is using just a basic BufferedReader wrapping an InputSteamReader for the server.  What exactly do you mean when you say "terminates with a newline"? 

               

              The end goal is for camel-netty to be the bridge between an external TCP Server/Client and JMS topics.  We do not have any control over the "External" server/client.

               

               

              External TCP Server -> -> some.topic.in -> Application (xml payload)

               

              External TCP Client <- <- some.topic.out <- Application (xml payload)

              • 4. Re: Simple Camel-Netty Examples/Issue?
                davsclaus

                Hi

                 

                We have some unit tests in camel-netty. For example this in only textline test

                https://svn.apache.org/repos/asf/camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTextlineInOnlyTest.java

                 

                Notice how we use \n to terminate the message. eg the textline codec needs a new line character at the end, so it knows when the message ends.

                • 5. Re: Simple Camel-Netty Examples/Issue?
                  dr8ball

                  After some more testing it appears that camel-netty client closes the socket after each message sent, since my test application was only accepting a single connection I was only seeing the first message.  I did not see this behavior when testing with the camel-mina component.  Is there something that I am missing in the configuration that would allow camel-netty to reuse the socket? 

                   

                  Is there any reasons that we should choose the camel-mina component over the camel-netty component?  Are you planning to support both equally or is one preferred over the other?

                  • 6. Re: Simple Camel-Netty Examples/Issue?
                    davsclaus

                    FuseSource supports all what we offer in our products.

                     

                    The camel-mina component is using the older Mina 1.x. There is a new camel-mina2 component in the works for Camel 2.10, that is using the new Mina 2.x releases.

                    • 7. Re: Simple Camel-Netty Examples/Issue?
                      davsclaus

                      That said, a lot of people is using the camel-mina component since it has been there for a very long time, and it just works.

                      • 8. Re: Simple Camel-Netty Examples/Issue?
                        dr8ball

                        OK, I think you have convinced me to go back to the camel-mina or camel-mina2 component but just so that I know, is there a way to prevent camel-netty from closing the socket after each message?

                         

                        Regarding camel-mina2, is there a way to create a consumer that acts as a client instead of a server?  I have seen the question in other threads but I wasn't sure if and how that would work in the camel-mina2 component.  If not, is there a work around?

                        • 9. Re: Simple Camel-Netty Examples/Issue?
                          davsclaus

                          There is some JIRAs to enhance camel-mina2 to let it act as a client as well. Somebody from the community said he wanted to contribute and works on it.

                          • 10. Re: Simple Camel-Netty Examples/Issue?
                            dr8ball

                            Thanks for the info Claus!  Is there a way that I can get in contact with the person who is working on this?  I have an immediate need and if possible would like to either test the current solution or aid with a new solution. 

                             

                            Also, I would still like to know if there is a solution to my netty question so that I can mark it as answered.  Is there a way to prevent camel-netty from closing the socket after each message?

                            • 11. Re: Simple Camel-Netty Examples/Issue?
                              davsclaus

                              Well camel-netty has the disconnect option, that by default is false

                              http://camel.apache.org/netty

                               

                              To get in touch with the guy then try to find the ASF Camel JIRA ticket and post a comment there. And/or post on the Camel @user mailing list to get attention.

                               

                              If you are a FuseSource subscriber you can use that channel to get help with this, such as influence our roadmap, get direct access to our engineering team who can help speedup this etc.

                              • 12. Re: Simple Camel-Netty Examples/Issue?
                                davsclaus

                                A new connection is created each time due this bug reported here

                                https://issues.apache.org/jira/browse/CAMEL-4556