Broker 10.15 | webMethods Broker Documentation | webMethods Broker Messaging Programmer's Guide | JMS Policy Based Client-Side Clustering | Overriding Cluster Policy | Specifying Cluster Policy Override At Runtime
 
Specifying Cluster Policy Override At Runtime
If you specify "Cluster Policy Override" in a cluster connection factory, the webMethods API for JMS sets the value of the WM_JMS_CLUSTER_NODES property of the first message to the Broker (or Brokers) to which the message was sent.
When a message is sent to a cluster governed by a cluster policy, the WM_JMS_CLUSTER_NODES property is not set for the first message. The webMethods API for JMS sends this message to the Broker (or Brokers) determined by the cluster policy. The webMethods API for JMS assigns this list of Broker(s) to the value of the WM_JMS_CLUSTER_NODES property of the message.
For the subsequent messages, you override the cluster policy by setting the WM_JMS_CLUSTER_NODES message property to the value obtained from the first message. Thereafter, the JMS client application sends the messages only to the Broker (or Brokers) to the Brokers specified in the WM_JMS_CLUSTER_NODES property.
For example, in case of Random policy, the webMethods API for JMS assigns the value of the WM_JMS_CLUSTER_NODES property of the first message to the Broker to which the message was sent. In case of Multisend Guaranteed policy or Multisend Best Effort policy, the first message is sent to multiple Brokers in the cluster; the webMethods API for JMS assigns the list of Brokers (to which the first message was sent) to the WM_JMS_CLUSTER_NODES property.
webMethods API for JMS throws an exception in the following cases:
*If only one Broker is specified in the WM_JMS_CLUSTER_NODES property, and the specified Broker is not available.
*If the cluster policy is Multisend Best Effort, and all the Brokers specified in the WM_JMS_CLUSTER_NODES property are not available.
*If the cluster policy is Multisend Guaranteed, and any one of the Brokers specified in the WM_JMS_CLUSTER_NODES property is not available.
Examples
*Set the WM_JMS_CLUSTER_NODES property to "Broker #2@localhost:6849" as follows:
pMessage.setStringProperty(WmMessage.WM_JMS_CLUSTER_NODES, "Broker
#2@localhost:6849");
*Set the cluster override flag in a cluster connection factory as follows:
WmQueueConnectionFactoryImpl queueCF = null;
queueCF = (WmQueueConnectionFactoryImpl) WmJMSFactory.
getQueueConnectionFactory(); queueCF.setClientGroup(clientGroup);
queueCF.setBrokerCluster(new String[]
{"Broker #1@localhost:6849","Broker2@localhost:6949",
"Broker3@localhost:7010"});
queueCF.setClusterPolicy(WmClusterPolicyManager.ROUND_ROBIN);
queueCF.setClusterPolicyOverride(true);