Broker 10.15 | webMethods Broker Documentation | webMethods Broker Messaging Programmer's Guide | JMS Policy Based Client-Side Clustering | Samples | Sample 3: Creating Composite Connection Factory
 
Sample 3: Creating Composite Connection Factory
This sample demonstrates how you can programmatically configure a composite connection factory using the webMethods API for JMS for client applications.
A composite cluster connection factory contains two child cluster connection factories: child cluster connection factory 1 and child cluster connection factory 2.
*To configure a composite factory
1. Create the a first child cluster connection factory using the webMethods API for JMS.
2. Set the Brokers in the first child cluster connection factory, and configure the first child cluster connection factory to use round robin load balancing policy.
3. Create the second child cluster connection factory.
4. Set the Brokers in the second child cluster connection factory, and configure the second child cluster connection factory to use sticky load balancing policy.
5. Assign the child cluster connection factories created in step 1 and 2 to the composite factory.
6. Configure the composite cluster connection factory to use the multisend guaranteed load balancing policy.
//Create the composite child Cluster Connection Factories using the API
WmConnectionFactory childFactory1 = WmJMSFactory.getXAConnectionFactory();
String[] brokerList = new String[2];
brokerList[0] = "Broker1@localhost:9100";
brokerList[1] = "Broker12@localhost:9200";
childFactory1.setClientGroup("JMSClient");
childFactory1.setBroker1Cluster(brokerList); //Set the Broker1 list
childFactory1.setClusterPolicy(WmClusterPolicyManager.ROUND_ROBIN);
//Cluster Policy
childFactory1.setClusterName("C1"); //Name of the cluster
childFactory1.setIncludeAllBroker1s(true); //Include all Broker1s in
   the cluster with the connection factory.

//Create the composite child Cluster Connection Factories using the API
WmConnectionFactory childFactory2 = WmJMSFactory.getXAConnectionFactory();
String[] brokerList2 = new String[2];
brokerList[0] = "Broker1A@localhost:9300";
brokerList[1] = "Broker1B@localhost:9400";
childFactory2.setClientGroup("JMSClient");
childFactory2.setBroker1Cluster(brokerList2); //Set the Broker1 list
childFactory2.setClusterPolicy(WmClusterPolicyManager.STICKY);
//Cluster Policy
childFactory2.setClusterName("C2"); //Name of the cluster
childFactory2.setIncludeAllBroker1s(true); //Include all Broker1s
   in the cluster with the connection factory.

WmConnectionFactory compositeFactory =
WmJMSFactory.getXAConnectionFactory();
CopyOnWriteArrayList<WmConnectionFactory> childConnFactories =
new CopyOnWriteArrayList<WmConnectionFactory>();
childConnFactories.add(childFactory1);
childConnFactories.add(childFactory2);

//Set the composite child factory list
compositeFactory.setCompositeChildConnFactories(childConnFactories);

//Cluster Policy at composite factory level
compositeFactory.setClusterPolicy(WmClusterPolicyManager.
MULTISEND_GUARANTEED);
compositeFactory.setMultiSendCount(2);