9 Replies Latest reply on Mar 1, 2012 12:08 PM by tomeicher

    JBESB-2805 - Splitter EAI Pattern

    rferreir

      Guys,

      What do you think about this feature request:

      https://jira.jboss.org/jira/browse/JBESB-2805

      It is about a implementation of the splitter EAI pattern. Based on the pattern, it create different messages from the original message and routes them to different message channels.

      I've uploaded a copy of the implementation in the JIRA request, and, if you feel confortable with the idea, I would be glad to see this feature available in the JBoss ESB / SOA Platform.

      What do you think?

      Regards,

      Ricardo Ferreira
      JBoss Solutions Architect, Brazil
      JBoss, by Red Hat [/url]

        • 1. Re: JBESB-2805 - Splitter EAI Pattern
          tfennelly

          Hey Ricardo.

          This looks great and I'm sure it would be a great addition to the ESB!!

          A few small comments...

          1. I think the implementation of the Splitter class could be optimized greatly.... create and cache the ServiceInvoker and Smooks instances up front, from the ConfigTree, as part of the constructor. I think this should make a huge difference to your performance.

          2. Load all the Smooks configs into one Smooks instance. Then, you can do all the splitting in a single pass of the message, versus iterating over the destination list. Again... this should make a big difference to performance!!

          3. I think a great extension to this action might be a "shorthand" config version where you don't need to specify a Smooks config at all. Instead, the route-to config just specifies an XML fragment path that the user wants split out of the message. Of course, this would only split and route XML fragments, but that's probably fine for many use cases.

          • 2. Re: JBESB-2805 - Splitter EAI Pattern
            rferreir

            Hi Tom,

            Thank you for your feedback. I'm going to implement your suggestions about performance, it makes sense totally. I've just not understood the third suggestion. When you say that in the "route-to" tag the user could just put a XML fragment, you meant use XPath? Or, the XML fragment that are written in the configuration IS the message that are to be sent for the message channel?

            Help me to understand this, please ;-)

            Regards,

            • 3. Re: JBESB-2805 - Splitter EAI Pattern
              rferreir

              Folks,

              As suggested by Tom (thanks Tom), I've made some improvements on the Splitter implementation. In the JIRA entry, there are this new implementation which make use of some cache mechanisms for the service invokers and smooks instances.

              Check it out: https://jira.jboss.org/jira/browse/JBESB-2805

              Regards,

              • 4. Re: JBESB-2805 - Splitter EAI Pattern
                tfennelly

                 

                "rferreir" wrote:
                I've just not understood the third suggestion. When you say that in the "route-to" tag the user could just put a XML fragment, you meant use XPath? Or, the XML fragment that are written in the configuration IS the message that are to be sent for the message channel?


                Right... so the fragments specified by the path can be filtered and serialized to XML, which are then routed to the specified service. Maybe it would be better to leave this for now and concentrate on the existing features and getting them right first. What do you think?

                It also just dawned on me Ricardo... looks like you're routing to the target service after filtering the complete message through Smooks. If so.... won't this then just work for a single fragment? What if you want to seperately split and route each order-item in an order i.e. so you need to be able to route multiple instances of the same fragment from a single message? Maybe it would be better to use the existing FragmentRouter class from the ESB, which basically wraps the ServiceInvoker inside a Smooks Visitor, allowing you to route fragments as part of the filtering process Vs doing it in batch at the end. What do you think?

                • 5. Re: JBESB-2805 - Splitter EAI Pattern
                  rferreir

                  Hi Tom,

                  Actually, the current implementation can route separated messages for the services, since every route-to request contain a smooks trans. The idea behind this is: You pass for the splitter a huge message (eg: An Complete Order), and the splitter process each smooks trans for this message, and the resulting messages (Eg: Separeted Items) are routed for the services.

                  Have said that, you can write custom smooks trans for each order of the message, which will cause the creation of separated messages for each service that waits for a item to be processed. Did you see the example that I've attached to the JIRA? It is a complete test scenario that does to different routings for the same message.

                  But let's talk about improvements. I've not work yeat with this FragmentRouter, I'm going to learn how it works and try to use in the implementation. Could you help in this class usage?

                  I've not found a description of this router in the programmers guide, I've only the source code. But it seems that I should instantiate a copy of this router for every routing that I'm planning to do, it's correct? If so, I've to pass a instance of a executionContext that wrapps a smooks transformed object.

                  Regards,

                  • 6. Re: JBESB-2805 - Splitter EAI Pattern
                    tfennelly

                     

                    "rferreir" wrote:
                    Actually, the current implementation can route separated messages for the services, since every route-to request contain a smooks trans. The idea behind this is: You pass for the splitter a huge message (eg: An Complete Order), and the splitter process each smooks trans for this message, and the resulting messages (Eg: Separeted Items) are routed for the services.


                    I must be reading the code incorrectly in that case Ricardo. I'll have a look at your example.

                    When I look at the code, it says to me, for each route-to config:
                    1. Apply a smooks.filterSource opp using the PayloadProcessor,
                    2. If there's a result, route it to the target service defined in the route-to.

                    So... as I read it, yes it may route multiple messages if there are multiple destinations configured, but it routes a max of one message to each destination for a given exec of the action. No?

                    "rferreir" wrote:
                    But let's talk about improvements. I've not work yeat with this FragmentRouter, I'm going to learn how it works and try to use in the implementation. Could you help in this class usage?

                    I've not found a description of this router in the programmers guide, I've only the source code. But it seems that I should instantiate a copy of this router for every routing that I'm planning to do, it's correct? If so, I've to pass a instance of a executionContext that wrapps a smooks transformed object.


                    Take a look at the smooks_file_splitter_router quickstart in the 4.6 release.

                    • 7. Re: JBESB-2805 - Splitter EAI Pattern
                      rferreir

                      Hi Tom,

                      Exactly! One execution of the splitter action causes that each route-to will receive a piece of the message sent to the splitter.

                      I'll look the sample to understand the FragmentRouter ;-)

                      Regards,

                      • 8. Re: JBESB-2805 - Splitter EAI Pattern
                        tfennelly

                         

                        "rferreir" wrote:
                        Exactly! One execution of the splitter action causes that each route-to will receive a piece of the message sent to the splitter.


                        Okidoki... so what FragmentRouter will let you do is support routing of multiple messages from a single messge i.e. split a single order message that contains 100 order-items into 100 individual messages that are routed individually, all in a single filtering pass over the message. In other words... 1:n instead of 1:1.

                        I think you'd need this, no?

                        • 9. Re: JBESB-2805 - Splitter EAI Pattern
                          tomeicher

                          This is what I would need right now :-)

                          Ricardo, any update on this over the years ?

                          Sadly, https://issues.jboss.org/browse/JBESB-2805 is still unresolved...

                          I found http://java.dzone.com/articles/jbossesb-smooks-integration - is this the way to go ?

                          Cheers, Tom.