LoadBalanceMBeanInvocations

Version 5

    (Note: a bug in the AS clustering code prevents the solution discussed on this page working properly in releases up to and including 5.0.0.GA unless specialized behavior is added to the mbean service. See the forum discussion related to the problem for an example of how to add the needed behavior to your service. This will not be necessary for releases after 5.0.0.GA.)

     

    It is possible to load balance MBean invocations between different MBean servers (AS instances). This solution assumes that you are going to access MBeans remotely using a similar solution to the one explained in the Accessing an HASingleton service remotely.

     

    The differences are:

    • for load balancing, you need to use an HA invoker, i.e.

      jboss:service=invoker,type=jrmpha

       

    • you need to define a load balance policy (use EJB Loadbalancing Policies), i.e.

      org.jboss.ha.framework.interfaces.RoundRobin

       

    • the cluster partition object name needs defining, i.e.

      jboss:service=DefaultPartition

       

     

    It's worth noting that:

    • HAServiceRemote is just a standard interface.

    • client side (Single)RetryInterceptor won't work with MBean invocations because they were designed with EJBs in mind (the code makes assumptions valid only for EJBs) and won't work with MBeans.

    • MBean state replication has not been implemented yet, so load balancing MBean invocations will only make sense with MBeans that don't mantain a state.

     

    Example: jmx-ha-service.xml

     

    <!-- Create JRMPHA proxy for the service that sends notifications -->
    
    <mbean code="org.jboss.proxy.generic.ProxyFactoryHA"
    name="jboss.test:service=ProxyFactory,name=HAService,protocol=jrmpha">
    
    <!-- Use the standard HA JRMPInvoker -->
    <depends optional-attribute-name="InvokerName">jboss:service=invoker,type=jrmpha</depends>
    
    <!-- The target MBean -->
    <depends optional-attribute-name="TargetName">jboss.test:service=HAService</depends>
    
    <!-- Where to bind the proxy -->
    <attribute name="JndiName">jmx/HAService</attribute>
    
    <!-- The load balancing policy -->
    <attribute name="LoadBalancePolicy">org.jboss.ha.framework.interfaces.RoundRobin</attribute>
    
    <!-- Use the default partition -->
    <depends optional-attribute-name="PartitionObjectName">jboss:service=DefaultPartition</depends>
    
    <!-- The interface exposed to the client -->
    <attribute name="ExportedInterface">org.jboss.test.jmx.ha.HAServiceRemote</attribute>
    
    <!-- Client side behaviour -->
    <attribute name="ClientInterceptors">
    <interceptors>
    <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
    <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
    </interceptors>
    </attribute>
    </mbean>