Enabling Load Balancing and Failover in Your JMS Applications
You need not change the code in your JMS applications to enable load balancing feature if JNDI provider is used to store the connection factory data. The webMethods API for JMS will enable or disable load balancing based on the existence of a Broker cluster and load balancing policy definition when a JMS connection is made.
If the connection factory is defined with only one
Broker or without a load balancing policy, all message publishing and receiving will be ordinary JMS messaging.
If the connection factory is associated with a
Broker cluster (multiple
Brokers) and a load balancing policy is specified, all the
Brokers in cluster will work as a single
Broker and distribute the messages according to the load balancing policy.
If your existing JMS application is using
Broker List feature, it is recommended that you update your code to use the load balancing clustering feature. For example, if your current code is similar to:
WmConnectionFactoryImpl cf = new WmConnectionFactoryImpl();
cf.setBrokerName("Broker #1");
cf.setBrokerHost("localhost:6849");
cf.setBrokerList("Broker #1@localhost:6849, Broker 2@localhost:6949");
cf.createConnection();
Update your code to use the JMS Policy based clustering feature by replacing setBrokerList() with setClusterPolicy() & setBrokerCluster():
WmConnectionFactoryImpl cf = new WmConnectionFactoryImpl();
cf.setClusterPolicy(WmClusterPolicyManager.STICKY);
cf.setBrokerCluster(new String[] {"Broker #1@localhost:6849",
"B2@localhost:6949", "B3@localhost:7010"});
cf.createConnection();
If you create a cluster using the user interface in My webMethods, the cluster validation process ensures that the specified Brokers are in the same cluster and synchronizes the document types and client groups details in all the Brokers in the cluster.
Note:webMethods Broker client-side clustering for JMS client applications does not validate at the webMethods API for JMS level to check if the specified Brokers are in the same cluster or not. Make sure that all the Brokers used for publishing and subscription are defined in the same cluster. All the Brokers in the cluster must have identical document type and client group information.