private void setAvailabilityProperties() throws ConnectorRuntimeException {
if(!isClustered()) return;
try {
Domain domain = Globals.get(Domain.class);
ServerContext serverContext = Globals.get(ServerContext.class);
Server server = domain.getServerNamed(serverContext.getInstanceName());
JmsService jmsService = server.getConfig().getExtensionByType(JmsService.class);
if (jmsService.getType().equals(REMOTE)) {
//If REMOTE, the broker cluster instances already have
//been configured with the right properties.
return;
}
AvailabilityService as = server.getConfig().getAvailabilityService();
if (as == null) {
logFine("Availability Service is null. Not setting AvailabilityProperties.");
return;
}
boolean useMasterBroker = true;
if(as.getExtensionByType(JmsAvailability.class) != null && ! MASTERBROKER.equalsIgnoreCase(as.getExtensionByType(JmsAvailability.class).getConfigStoreType()))
useMasterBroker = false;
//jmsService.getUseMasterBroker() != null ? Boolean.valueOf(jmsService.getUseMasterBroker()) :true;
boolean isJmsAvailabilityEnabled = this.isJMSAvailabilityOn(as);
logFine("Setting AvailabilityProperties .. ");
if (!useMasterBroker || isJmsAvailabilityEnabled) {
// For conventional cluster of peer brokers and Enhanced Broker Cluster.
ConnectorDescriptor cd = getDescriptor();
String clusterName = getMQClusterName();
ConnectorConfigProperty envProp1 = new ConnectorConfigProperty (
CLUSTERID , clusterName,"Cluster Id",
"java.lang.String");
setProperty(cd, envProp1);
if(brokerInstanceName == null) {
brokerInstanceName = getBrokerInstanceName(jmsService);
}
ConnectorConfigProperty envProp2 = new ConnectorConfigProperty (
BROKERID , brokerInstanceName,"Broker Id",
"java.lang.String");
setProperty(cd, envProp2);
//Only if JMS availability is true - Enhanced Broker Cluster only.
if (isJmsAvailabilityEnabled) {
//Set HARequired as true - irrespective of whether it is REMOTE or
//LOCAL
ConnectorConfigProperty envProp3 = new ConnectorConfigProperty (
HAREQUIRED , "true","HA Required",
"java.lang.String");
setProperty(cd, envProp3);
/* The broker has a property to control whether
* it starts in HA mode or not and that's represented on
* the RA by BrokerEnableHA.
* On the MQ Client connection side it is HARequired -
* this does not control the broker, it just is a client
* side requirement.
* So for AS EE, if BrokerType is LOCAL or EMBEDDED,
* and AS HA is enabled for JMS then both these must be
* set to true. */
ConnectorConfigProperty envProp4 = new ConnectorConfigProperty (
BROKERENABLEHA , "true",
"BrokerEnableHA flag","java.lang.Boolean");
setProperty(cd, envProp4);
String nodeHostName = domain.getNodeNamed(server.getNodeRef()).getNodeHost();
if (nodeHostName != null) {
ConnectorConfigProperty envProp5 = new ConnectorConfigProperty (
BROKERBINDADDRESS , nodeHostName,
"Broker Bind Address","java.lang.String");
setProperty(cd, envProp5);