This closes #1269
This commit is contained in:
commit
17e3f6fb37
|
@ -23,12 +23,6 @@ import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
|
|||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQQueueConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQTopicConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQXAQueueConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQXATopicConnectionFactory;
|
||||
import org.apache.activemq.artemis.uri.ConnectionFactoryParser;
|
||||
|
||||
/**
|
||||
|
@ -64,22 +58,7 @@ public class ActiveMQJMSClient {
|
|||
*/
|
||||
public static ActiveMQConnectionFactory createConnectionFactoryWithHA(final DiscoveryGroupConfiguration groupConfiguration,
|
||||
JMSFactoryType jmsFactoryType) {
|
||||
ActiveMQConnectionFactory factory = null;
|
||||
if (jmsFactoryType.equals(JMSFactoryType.CF)) {
|
||||
factory = new ActiveMQJMSConnectionFactory(true, groupConfiguration);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) {
|
||||
factory = new ActiveMQQueueConnectionFactory(true, groupConfiguration);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) {
|
||||
factory = new ActiveMQTopicConnectionFactory(true, groupConfiguration);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) {
|
||||
factory = new ActiveMQXAConnectionFactory(true, groupConfiguration);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) {
|
||||
factory = new ActiveMQXAQueueConnectionFactory(true, groupConfiguration);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) {
|
||||
factory = new ActiveMQXATopicConnectionFactory(true, groupConfiguration);
|
||||
}
|
||||
|
||||
return factory;
|
||||
return jmsFactoryType.createConnectionFactoryWithHA(groupConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,22 +72,7 @@ public class ActiveMQJMSClient {
|
|||
*/
|
||||
public static ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final DiscoveryGroupConfiguration groupConfiguration,
|
||||
JMSFactoryType jmsFactoryType) {
|
||||
ActiveMQConnectionFactory factory = null;
|
||||
if (jmsFactoryType.equals(JMSFactoryType.CF)) {
|
||||
factory = new ActiveMQJMSConnectionFactory(false, groupConfiguration);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) {
|
||||
factory = new ActiveMQQueueConnectionFactory(false, groupConfiguration);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) {
|
||||
factory = new ActiveMQTopicConnectionFactory(false, groupConfiguration);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) {
|
||||
factory = new ActiveMQXAConnectionFactory(false, groupConfiguration);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) {
|
||||
factory = new ActiveMQXAQueueConnectionFactory(false, groupConfiguration);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) {
|
||||
factory = new ActiveMQXATopicConnectionFactory(false, groupConfiguration);
|
||||
}
|
||||
|
||||
return factory;
|
||||
return jmsFactoryType.createConnectionFactoryWithoutHA(groupConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,22 +93,7 @@ public class ActiveMQJMSClient {
|
|||
*/
|
||||
public static ActiveMQConnectionFactory createConnectionFactoryWithHA(JMSFactoryType jmsFactoryType,
|
||||
final TransportConfiguration... initialServers) {
|
||||
ActiveMQConnectionFactory factory = null;
|
||||
if (jmsFactoryType.equals(JMSFactoryType.CF)) {
|
||||
factory = new ActiveMQJMSConnectionFactory(true, initialServers);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) {
|
||||
factory = new ActiveMQQueueConnectionFactory(true, initialServers);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) {
|
||||
factory = new ActiveMQTopicConnectionFactory(true, initialServers);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) {
|
||||
factory = new ActiveMQXAConnectionFactory(true, initialServers);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) {
|
||||
factory = new ActiveMQXAQueueConnectionFactory(true, initialServers);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) {
|
||||
factory = new ActiveMQXATopicConnectionFactory(true, initialServers);
|
||||
}
|
||||
|
||||
return factory;
|
||||
return jmsFactoryType.createConnectionFactoryWithHA(initialServers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,22 +109,7 @@ public class ActiveMQJMSClient {
|
|||
*/
|
||||
public static ActiveMQConnectionFactory createConnectionFactoryWithoutHA(JMSFactoryType jmsFactoryType,
|
||||
final TransportConfiguration... transportConfigurations) {
|
||||
ActiveMQConnectionFactory factory = null;
|
||||
if (jmsFactoryType.equals(JMSFactoryType.CF)) {
|
||||
factory = new ActiveMQJMSConnectionFactory(false, transportConfigurations);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) {
|
||||
factory = new ActiveMQQueueConnectionFactory(false, transportConfigurations);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) {
|
||||
factory = new ActiveMQTopicConnectionFactory(false, transportConfigurations);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) {
|
||||
factory = new ActiveMQXAConnectionFactory(false, transportConfigurations);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) {
|
||||
factory = new ActiveMQXAQueueConnectionFactory(false, transportConfigurations);
|
||||
} else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) {
|
||||
factory = new ActiveMQXATopicConnectionFactory(false, transportConfigurations);
|
||||
}
|
||||
|
||||
return factory;
|
||||
return jmsFactoryType.createConnectionFactoryWithoutHA(transportConfigurations);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,9 +16,144 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.api.jms;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQQueueConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQTopicConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQXATopicConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQXAQueueConnectionFactory;
|
||||
|
||||
// XXX no javadocs
|
||||
public enum JMSFactoryType {
|
||||
CF, QUEUE_CF, TOPIC_CF, XA_CF, QUEUE_XA_CF, TOPIC_XA_CF;
|
||||
CF {
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithHA(final DiscoveryGroupConfiguration groupConfiguration) {
|
||||
return new ActiveMQJMSConnectionFactory(true, groupConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final DiscoveryGroupConfiguration groupConfiguration) {
|
||||
return new ActiveMQJMSConnectionFactory(false, groupConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithHA(final TransportConfiguration... initialServers) {
|
||||
return new ActiveMQJMSConnectionFactory(true, initialServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final TransportConfiguration... transportConfigurations) {
|
||||
return new ActiveMQJMSConnectionFactory(false, transportConfigurations);
|
||||
}
|
||||
},
|
||||
QUEUE_CF {
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithHA(final DiscoveryGroupConfiguration groupConfiguration) {
|
||||
return new ActiveMQQueueConnectionFactory(true, groupConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final DiscoveryGroupConfiguration groupConfiguration) {
|
||||
return new ActiveMQQueueConnectionFactory(false, groupConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithHA(final TransportConfiguration... initialServers) {
|
||||
return new ActiveMQQueueConnectionFactory(true, initialServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final TransportConfiguration... transportConfigurations) {
|
||||
return new ActiveMQQueueConnectionFactory(false, transportConfigurations);
|
||||
}
|
||||
},
|
||||
TOPIC_CF {
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithHA(final DiscoveryGroupConfiguration groupConfiguration) {
|
||||
return new ActiveMQTopicConnectionFactory(true, groupConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final DiscoveryGroupConfiguration groupConfiguration) {
|
||||
return new ActiveMQTopicConnectionFactory(false, groupConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithHA(final TransportConfiguration... initialServers) {
|
||||
return new ActiveMQTopicConnectionFactory(true, initialServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final TransportConfiguration... transportConfigurations) {
|
||||
return new ActiveMQTopicConnectionFactory(false, transportConfigurations);
|
||||
}
|
||||
},
|
||||
XA_CF {
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithHA(final DiscoveryGroupConfiguration groupConfiguration) {
|
||||
return new ActiveMQXAConnectionFactory(true, groupConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final DiscoveryGroupConfiguration groupConfiguration) {
|
||||
return new ActiveMQXAConnectionFactory(false, groupConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithHA(final TransportConfiguration... initialServers) {
|
||||
return new ActiveMQXAConnectionFactory(true, initialServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final TransportConfiguration... transportConfigurations) {
|
||||
return new ActiveMQXAConnectionFactory(false, transportConfigurations);
|
||||
}
|
||||
},
|
||||
QUEUE_XA_CF {
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithHA(final DiscoveryGroupConfiguration groupConfiguration) {
|
||||
return new ActiveMQXAQueueConnectionFactory(true, groupConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final DiscoveryGroupConfiguration groupConfiguration) {
|
||||
return new ActiveMQXAQueueConnectionFactory(false, groupConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithHA(final TransportConfiguration... initialServers) {
|
||||
return new ActiveMQXAQueueConnectionFactory(true, initialServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final TransportConfiguration... transportConfigurations) {
|
||||
return new ActiveMQXAQueueConnectionFactory(false, transportConfigurations);
|
||||
}
|
||||
},
|
||||
TOPIC_XA_CF {
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithHA(final DiscoveryGroupConfiguration groupConfiguration) {
|
||||
return new ActiveMQXATopicConnectionFactory(true, groupConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final DiscoveryGroupConfiguration groupConfiguration) {
|
||||
return new ActiveMQXATopicConnectionFactory(false, groupConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithHA(final TransportConfiguration... initialServers) {
|
||||
return new ActiveMQXATopicConnectionFactory(true, initialServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final TransportConfiguration... transportConfigurations) {
|
||||
return new ActiveMQXATopicConnectionFactory(false, transportConfigurations);
|
||||
}
|
||||
};
|
||||
|
||||
public int intValue() {
|
||||
int val = 0;
|
||||
|
@ -72,4 +207,62 @@ public enum JMSFactoryType {
|
|||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ActiveMQConnectionFactory that receives cluster topology updates from the cluster as
|
||||
* servers leave or join and new backups are appointed or removed.
|
||||
* <p>
|
||||
* The discoveryAddress and discoveryPort parameters in this method are used to listen for UDP
|
||||
* broadcasts which contain connection information for members of the cluster. The broadcasted
|
||||
* connection information is simply used to make an initial connection to the cluster, once that
|
||||
* connection is made, up to date cluster topology information is downloaded and automatically
|
||||
* updated whenever the cluster topology changes. If the topology includes backup servers that
|
||||
* information is also propagated to the client so that it can know which server to failover onto
|
||||
* in case of live server failure.
|
||||
*
|
||||
* @param groupConfiguration
|
||||
* @return the ActiveMQConnectionFactory
|
||||
*/
|
||||
public abstract ActiveMQConnectionFactory createConnectionFactoryWithHA(final DiscoveryGroupConfiguration groupConfiguration);
|
||||
|
||||
/**
|
||||
* Create an ActiveMQConnectionFactory which creates session factories from a set of live servers, no HA backup information is propagated to the client
|
||||
* <p>
|
||||
* The UDP address and port are used to listen for live servers in the cluster
|
||||
*
|
||||
* @param groupConfiguration
|
||||
* @return the ActiveMQConnectionFactory
|
||||
*/
|
||||
public abstract ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final DiscoveryGroupConfiguration groupConfiguration);
|
||||
|
||||
/**
|
||||
* Create an ActiveMQConnectionFactory which will receive cluster topology updates from the cluster
|
||||
* as servers leave or join and new backups are appointed or removed.
|
||||
* <p>
|
||||
* The initial list of servers supplied in this method is simply to make an initial connection to
|
||||
* the cluster, once that connection is made, up to date cluster topology information is
|
||||
* downloaded and automatically updated whenever the cluster topology changes. If the topology
|
||||
* includes backup servers that information is also propagated to the client so that it can know
|
||||
* which server to failover onto in case of live server failure.
|
||||
*
|
||||
* @param initialServers The initial set of servers used to make a connection to the cluster.
|
||||
* Each one is tried in turn until a successful connection is made. Once a connection
|
||||
* is made, the cluster topology is downloaded and the rest of the list is ignored.
|
||||
* @return the ActiveMQConnectionFactory
|
||||
*/
|
||||
public abstract ActiveMQConnectionFactory createConnectionFactoryWithHA(final TransportConfiguration... initialServers);
|
||||
|
||||
/**
|
||||
* Create an ActiveMQConnectionFactory which creates session factories using a static list of
|
||||
* transportConfigurations.
|
||||
* <p>
|
||||
* The ActiveMQConnectionFactory is not updated automatically as the cluster topology changes, and
|
||||
* no HA backup information is propagated to the client
|
||||
*
|
||||
* @param transportConfigurations
|
||||
* @return the ActiveMQConnectionFactory
|
||||
*/
|
||||
public abstract ActiveMQConnectionFactory createConnectionFactoryWithoutHA(final TransportConfiguration... transportConfigurations);
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue