3 Replies Latest reply on Jun 30, 2008 8:08 AM by marklittle

    fine-garined vs coarse-grained services

    evanyang

      I have a generic design question regarding how to define esb services, here is an example:

      I have 3 fine-grained services A, B and C, ideally I should define an esb service to hide the routing/transformation/etc. of these 3 services, so client only talk to this esb service.

      so in the jboss-esb.xml, we may have this:

      <services>
       <service category="mycategory" name="myservice" description="something">
       <listeners>...</listeners>
       <action mep="oneWay">
       <action name="serviceA" class="..." />
       <action name="serviceB" class="..." />
       <action name="serviceC" class="..." />
       </service>
       </services>
      


      But take a deeper look at the logic surround the services:

      1. service A actually need to have CBR for even more find-grained services:
      if rule 1 route to A-1
      if rule 2 route to A-2
      etc.

      2. the service B and C may also can grow with even finer services

      The new service can be like this:

      <services>
       <service category="mycategory" name="myservice" description="something">
       <listeners>...</listeners>
       <action mep="oneWay">
       <action class="org.jboss.soa.esb.actions.ContentBasedRouter" name="ContentBasedRouter">
       ....
       <property name="destinations">
       <route-to destination-name="x" service-category="mycategoryA1BC" service-name="myserviceA1BC/>
       <route-to destination-name="y" service-category="mycategoryA2BC" service-name="mysericeA2BC"/>
       </property>
       ....
       </service>
       <service category="mycategoryA1BC" name="myserviceA1BC" description="something">
       <action name="serviceA1" class="..." />
       <action name="serviceB" class="..." />
       <action name="serviceC" class="..." />
       </service>
       <service category="mycategoryaA2BC" name="myserviceA2BC" description="something">
       <action name="serviceA2" class="..." />
       <action name="serviceB" class="..." />
       <action name="serviceC" class="..." />
       </service>
       </services>
      


      and it can grow complicate soon.

      So my question is how to define fine-grained service and can be used by a coarse-grained service all inside the esb? something like this:

      <services>
       <service category="mycategoryA" name="myserviceA" description="something">
       ....
       <action mep="oneWay">
       <action class="org.jboss.soa.esb.actions.ContentBasedRouter" name="ContentBasedRouter">
       ....
       <property name="destinations">
       <route-to destination-name="x" service-category="mycategoryA1" service-name="myserviceA1/>
       <route-to destination-name="y" service-category="mycategoryA2" service-name="mysericeA2"/>
       </property>
       ....
       </service>
       <service category="mycategoryA1" name="myserviceA1" description="something">
       <action name="serviceA1" class="..." />
       </service>
       <service category="mycategoryA2" name="myserviceA2" description="something">
       <action name="serviceA2" class="..." />
       </service>
      
       <service category="mycategoryB" name="myserviceB" description="something">
       <action name="serviceB1" class="..." />
       <action name="serviceB2" class="..." />
       </service>
      
       <service category="mycategoryC" name="myserviceC" description="something">
       <action name="serviceC1" class="..." />
       <action name="serviceC2" class="..." />
       </service>
      
       <service category="mycategory" name="myservice" description="something">
       <listeners>...</listeners>
       <action mep="oneWay">
       <action name="serviceA" class="call myserviceA mycategoryA" />
       <action name="serviceB" class="call myserviceB mycategoryC" />
       <action name="serviceC" class="call myserviceD mycategoryD />
       </service>
       </services>
      


      What is the best practice in design of services?
      Thanks

      Evan


        • 1. Re: fine-garined vs coarse-grained services
          marklittle

          Are you interested in loose coupling and coherency between your services?

          • 2. Re: fine-garined vs coarse-grained services
            evanyang

            Lose coupling is a must, not just between the client and services but also between services. The coherence should only exist at the coarse-grained level. A fine-grain service should be a self-sufficient. This is my opinion.

            So my question is that in JbossESb (I have not worked on any other product) can I define fine-grained services and be wrapped/invoked by a coarse-grained one, or any sort of pattern to achieve this goal?

            • 3. Re: fine-garined vs coarse-grained services
              marklittle

              Loose coupling and fine-granularity are not commonly used together. The last thing you want to be doing is exposing individual objects on to the bus: obviously that is the finest level of granularity that you can find.

              I would suggest you check out the articles we've posted before.