10 Replies Latest reply on May 12, 2009 8:16 AM by maxogm

    Example how to use LoadBalancingFactory

    maxogm

      Hi,
      did anyone has some example how to use LoadBalancingFactory...
      Thanks

        • 1. Re: Example how to use LoadBalancingFactory
          gaohoward

          Can you give more info on your questions. for example:

          What do you refer LoadBalancingFactory to? JBM version? What purpose do you want it for? Thanks.

          • 2. Re: Example how to use LoadBalancingFactory
            maxogm

            I try to test max number of clients in Jboss messaging 1.4.2.

            I started two Jboss instance:

            run.bat -c node1 -b 10.113.1.158 -Djboss.messaging.ServerPeerID=1
            run.bat -c node2 -b 10.113.1.218 -Djboss.messaging.ServerPeerID=2


            and in my client I used:

            ConnectionFactory cf = (ConnectionFactory) context.lookup("/ClusteredConnectionFactory");


            but LoadBalancing did not work.

            After that I guess I must use LoadBalancingFactory.
            Maybe I mistake, I'm new to all this.

            • 3. Re: Example how to use LoadBalancingFactory
              gaohoward

              JBM 1.4 supports round-robin policy. I think you didn't set up your cluster correctly.

              For clarity, 'loadbalancing' means for the connection here, that is, the connections to the cluster are round roubined across the nodes.

              Take a look at distributed-queue example, if you can run this example, the cluster will be ok, and load balancing is working.

              • 4. Re: Example how to use LoadBalancingFactory
                maxogm

                I started two JBoss 5.0.1GA instance:

                run.bat -c node1 -Djboss.service.binding.set=ports-01 -b 10.133.1.158
                run.bat -c node2 -Djboss.service.binding.set=ports-02 -Djboss.messaging.ServerPeerID=1 -b 10.133.1.218
                

                node1 and node2 are copy of all configuration

                After that I make project in eclipse, in the project i copy 'distributed-topic' example from jboss-messaging-1.4.2GA-sp1...
                When I debug application... application will stop on line:

                cf = (ConnectionFactory)ic.lookup("/ClusteredConnectionFactory");
                


                I checked in connection-factories-service.xml file, and i have:

                 <mbean code="org.jboss.jms.server.connectionfactory.ConnectionFactory"
                 name="jboss.messaging.connectionfactory:service=ClusteredConnectionFactory"
                 xmbean-dd="xmdesc/ConnectionFactory-xmbean.xml">
                 <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
                 <depends optional-attribute-name="Connector">jboss.messaging:service=Connector,transport=bisocket</depends>
                 <depends>jboss.messaging:service=PostOffice</depends>
                
                 <attribute name="JNDIBindings">
                 <bindings>
                 <binding>/ClusteredConnectionFactory</binding>
                 <binding>/ClusteredXAConnectionFactory</binding>
                 <binding>java:/ClusteredConnectionFactory</binding>
                 <binding>java:/ClusteredXAConnectionFactory</binding>
                 </bindings>
                 </attribute>
                
                 <attribute name="SupportsFailover">true</attribute>
                 <attribute name="SupportsLoadBalancing">true</attribute>
                 </mbean>
                



                I did not do any editing on Jboss, just download, unzip and start

                • 5. Re: Example how to use LoadBalancingFactory
                  gaohoward

                  OK. I guess you need to change the jndi.properties in the example's etc dir.

                  • 6. Re: Example how to use LoadBalancingFactory
                    timfox

                     

                    "maxogm" wrote:
                    Hi,
                    did anyone has some example how to use LoadBalancingFactory...
                    Thanks


                    http://www.jboss.org/file-access/default/members/jbossmessaging/freezone/docs/userguide-1.4.3.GA/html_single/index.html#conf.connectionfactory.attributes.loadbalancingfactory

                    • 7. Re: Example how to use LoadBalancingFactory
                      maxogm

                      Works.... Thanks

                      I mistake in client Contex.

                      One more question, did subscriber must listen all nodes in cluster... as in the example 'distributed-topic'

                      • 8. Re: Example how to use LoadBalancingFactory
                        gaohoward

                        Re: One more question, did subscriber must listen all nodes in cluster... as in the example 'distributed-topic'

                        No, it needn't. The load-balance is transparent to applications.

                        • 9. Re: Example how to use LoadBalancingFactory
                          maxogm

                           

                          "gaohoward" wrote:

                          No, it needn't. The load-balance is transparent to applications.


                          When I create just one listener in cluster with two nodes... I receive only half messages... :(

                          • 10. Re: Example how to use LoadBalancingFactory
                            maxogm

                            Did anyone known what is problem, load-balance is not transparent to client.
                            My Publesher works OK, one time is publish on node1 other time on node2... But Subscriber, could not listen all nodes... only one.