9 Replies Latest reply on Jun 10, 2009 4:19 AM by sriram_imshriram

    ESB end point or a Camel end point

    sriram_imshriram

      Hi,

      I am new to java as well as FUSE. I am just trying to undersand the difference between the ESB (ServiceMix end point and CAMEL end point).

       

      And also, considering the following scenario, can you please give me some inputs on how to acheive it?

       

      I am subscribed to a JMS producer. When i receive a message(XML), depending on a particular info, I invoke a bean method to fetch a better detailed XML from the source.

      i.e the source send me an message like

       

      Whenever i receive the Ticket closed info, i need to call a bean method to obtain more information and then use the camel router.

      I can use filters to take no action when unwanted messages are received but to call anotehr bean method from the router is something I am not sure if acheivable.(Should this condition check be made in ESB or CAMEL?)

       

      It would be great if someone can help me in this regard.

        • 1. Re: ESB end point or a Camel end point
          socallag

          It sounds like Content Based Routing is probably the approach that best suits you, http://camel.apache.org/content-based-router.html.

           

          You can deploy the Mediation Router within the ESB which will provide you with additional lifecycle management capabilities and the features and benfits of OSGi.

          • 2. Re: ESB end point or a Camel end point
            davsclaus

            Hi

             

            Welcome to the FUSE community.

             

            You requirements can be described in EIP patterns and what you are talking about is:

            - filter

            - content based router

             

            Camel is build with EIP as being first class citizen.

            All these EIP is implemented:

            http://camel.apache.org/enterprise-integration-patterns.html

             

            The content based router in Camel can also filter unwanted messages so we can use this single EIP (they are routed to the otherwise, that you can omit):

            http://camel.apache.org/content-based-router.html

             

            So a pseudo route what you want to do would be:

             

            from(jms queue)

              - choice

                 - when ( ticket closed ) -> bean ( SomeBean, somemethod )

             

            As Camel have support for expressing the route in different domain languages (DSL) for example: Java code, Spring XML, Scala (Groovy and others).

            But mostly Java or Spring XML is used.

             

            In Java DSL it could be:

             

            from("activemq:queue:tickets")

              .choice()

                 .when().xpath("//message/text() = 'Ticket closed'").bean(MyBeanClass.class, "myMethod");

             

            Mind the xpath expression might need a tweak to get working.

             

            Invoking the bean can be done in multiple ways. As above we invoke it directly as you specify the class and method name. But the bean could also be a reference to a bean id in a Spring XML file etc. Then use .beanRef for that.

             

            You can see a bit more about content based router EIP here:

            http://camel.apache.org/content-based-router.html

             

            And xpath:

            http://camel.apache.org/xpath.html

             

            And when Camel invokes a bean it uses bean parameter binding to automatic converter to the parameter types defined in the method signature.

            http://camel.apache.org/bean-binding.html

             

            And you can help Camel by providing annotations

            http://camel.apache.org/parameter-binding-annotations.html

            • 3. Re: ESB end point or a Camel end point
              sriram_imshriram

              Thanks to davsclaus  and Seanoc. Your responses were very useful to me(I understand the capabilities of Camel more and more).

               

              Further trying to implement davsclaus' idea

               

              the thing is, my Bean class returns an XML that needs to transformed using an XSLT, and then only be routed, Is it possible to accomodate this in Camel itself?

              i.e conditional call to bean class followed by an XSLT transforamtion?

              (please tell me know if its a design flaw to do so, I am a newbie less than an year's exp in Enterpise Arch)

               

              Adding to this,

              Is there a way i could use the following code usd up in my ESB?

              (This is m existing code to subscribe to a topic)

              session.publishing.subscribe(myListener, myFilters);

               

              where is

              myListener = new custom.Listener(){

                          gotNotified(){

                            //This method gets invoked whenever my Publisher publishes.

                         }

              };

               

              I cannot change this code since only this can be used for notification a third party.

              How can i acheive the same thing using ESB using an JMS end point?

               

              Help greatly appreciated.

              • 4. Re: ESB end point or a Camel end point
                sriram_imshriram

                Follow up questions in the same thread

                • 5. Re: ESB end point or a Camel end point
                  davsclaus

                  Hi

                   

                  Yes you can do that in Camel. In fact its so easy as just to add what you want to do next, after the bean call.

                   

                  So if you want to do XST after the bean call, just add

                  .to("xslt:file://mytransformfile.xsl")

                  after the bean call.

                   

                  See about XSLT component

                  http://camel.apache.org/xslt

                  • 6. Re: ESB end point or a Camel end point
                    davsclaus

                    About the topic listener.

                     

                    Is it a JMS topic?

                     

                    In Camel you just add a 2nd route that will listen on the topic such as:

                     

                    For instance:

                    from("activemq:topic:myTopic").to("log:foo").beanRef(MyTopicBean.class, "hello");

                    • 7. Re: ESB end point or a Camel end point
                      sriram_imshriram

                      Thanks to davsclaus once again. Your suggestions are very useful to me.

                       

                      Yes it is a JMS topic.

                       

                      And i want to implement that JMS End point in Service Mix. So this brings me to the thread,

                      I need to implement this listener in ESB, when it receives the message i need to process this in CAMEL.

                      As you have said processing in CAMEL is very much possible, my doubt is how to implement this in ESB? (the same code provided in my last message)

                       

                      Sorry if these are lame questions, I am just a beginner trying to understand things around. Sorry for the trouble.

                      • 8. Re: ESB end point or a Camel end point
                        davsclaus

                        Hi

                         

                        No questions is lame and using both Camel and SMX is possible.

                         

                        However as they are separate Apache projects the documentation at Apache is not always super best.

                         

                        Camel have a bit on JBI

                        http://camel.apache.org/jbi

                         

                        The key is that in Camel you should use the jbi component to consume messages from SMX.

                         

                        So instead of from("activemq:topic:foo") you use from("jbi:xxxxx") where XXXX can be either service, endpoint and whatnot. See the wiki page.

                         

                        There are some links in the bottom of the Camel JBI page for other pages such as:

                        http://servicemix.apache.org/3-beginner-using-apache-camel-inside-servicemix.html

                        • 9. Re: ESB end point or a Camel end point
                          sriram_imshriram

                          Thanks for your great help. This helped me progress more. Thank you very much.