ARTEMIS-3331 - RA improvements to work well with more Servers

https://issues.apache.org/jira/browse/ARTEMIS-3331
This commit is contained in:
Andy Taylor 2021-06-02 10:59:43 +01:00 committed by clebertsuconic
parent 3ff70cb7d3
commit 88122e0cd1
10 changed files with 173 additions and 56 deletions

View File

@ -958,7 +958,9 @@ public class ActiveMQConnectionFactory extends JNDIStorable implements Connectio
@Override
protected void finalize() throws Throwable {
try {
serverLocator.close();
if (serverLocator != null) {
serverLocator.close();
}
} catch (Exception e) {
e.printStackTrace();
//not much we can do here

View File

@ -47,9 +47,11 @@ import javax.jms.IllegalStateException;
public interface ActiveMQRALogger extends BasicLogger {
/**
* The default logger.
* The default logger. Note this uses ActiveMQRALogger.class.getName() instead of ActiveMQRALogger.class.getPackage().getName()
* like the other loggers, this is because some Application Servers use introspection to identify properties which can
* sometimes use a classloader when the rar is uploaded and its possible getpackage() can return null
*/
ActiveMQRALogger LOGGER = Logger.getMessageLogger(ActiveMQRALogger.class, ActiveMQRALogger.class.getPackage().getName());
ActiveMQRALogger LOGGER = Logger.getMessageLogger(ActiveMQRALogger.class, ActiveMQRALogger.class.getName());
@LogMessage(level = Logger.Level.INFO)
@Message(id = 151000, value = "awaiting topic/queue creation {0}", format = Message.Format.MESSAGE_FORMAT)

View File

@ -39,7 +39,16 @@ public class ActiveMQRAMCFProperties extends ConnectionFactoryProperties impleme
* The topic type
*/
private static final String TOPIC_TYPE = Topic.class.getName();
protected boolean allowLocalTransactions;
/**
* If true then for outbound connections a local tx will be used if no JTA is configured
*/
private boolean allowLocalTransactions;
/**
* If true then for outbound connections will always assume that they are part of a transaction.
* This is helpful when running in containers where access to the Transaction manager can't be configured
*/
private boolean inJtaTransaction;
private String strConnectorClassName;
@ -176,4 +185,12 @@ public class ActiveMQRAMCFProperties extends ConnectionFactoryProperties impleme
public void setAllowLocalTransactions(boolean allowLocalTransactions) {
this.allowLocalTransactions = allowLocalTransactions;
}
public boolean isInJtaTransaction() {
return inJtaTransaction;
}
public void setInJtaTransaction(boolean inJtaTransaction) {
this.inJtaTransaction = inJtaTransaction;
}
}

View File

@ -63,11 +63,16 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti
*/
private ActiveMQConnectionFactory recoveryConnectionFactory;
/*
* The resource recovery if there is one
* */
/**
* The resource recovery if there is one
*/
private XARecoveryConfig resourceRecovery;
/**
* Used to configure whether the connection should be part of the JTA TX. This is when the RA doesn not have access to the Transaction manager to deduct whether this is the case.
*/
private boolean inJtaTransaction;
/**
* Constructor
*/
@ -508,6 +513,13 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti
mcfProperties.setMinLargeMessageSize(minLargeMessageSize);
}
/**
* A getter as well as a setter for those servers that use introspection
*/
public Boolean getBlockOnAcknowledge() {
return mcfProperties.isBlockOnAcknowledge();
}
public Boolean isBlockOnAcknowledge() {
return mcfProperties.isBlockOnAcknowledge();
}
@ -516,6 +528,13 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti
mcfProperties.setBlockOnAcknowledge(blockOnAcknowledge);
}
/**
* A getter as well as a setter for those servers that use introspection
*/
public Boolean getBlockOnNonDurableSend() {
return mcfProperties.isBlockOnNonDurableSend();
}
public Boolean isBlockOnNonDurableSend() {
return mcfProperties.isBlockOnNonDurableSend();
}
@ -524,6 +543,13 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti
mcfProperties.setBlockOnNonDurableSend(blockOnNonDurableSend);
}
/**
* A getter as well as a setter for those servers that use introspection
*/
public Boolean getBlockOnDurableSend() {
return mcfProperties.isBlockOnDurableSend();
}
public Boolean isBlockOnDurableSend() {
return mcfProperties.isBlockOnDurableSend();
}
@ -532,6 +558,13 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti
mcfProperties.setBlockOnDurableSend(blockOnDurableSend);
}
/**
* A getter as well as a setter for those servers that use introspection
*/
public Boolean getAutoGroup() {
return mcfProperties.isAutoGroup();
}
public Boolean isAutoGroup() {
return mcfProperties.isAutoGroup();
}
@ -540,6 +573,13 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti
mcfProperties.setAutoGroup(autoGroup);
}
/**
* A getter as well as a setter for those servers that use introspection
*/
public Boolean getPreAcknowledge() {
return mcfProperties.isPreAcknowledge();
}
public Boolean isPreAcknowledge() {
return mcfProperties.isPreAcknowledge();
}
@ -572,6 +612,13 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti
mcfProperties.setReconnectAttempts(reconnectAttempts);
}
/**
* A getter as well as a setter for those servers that use introspection
*/
public Boolean getUseGlobalPools() {
return mcfProperties.isUseGlobalPools();
}
public Boolean isUseGlobalPools() {
return mcfProperties.isUseGlobalPools();
}
@ -580,6 +627,13 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti
mcfProperties.setUseGlobalPools(useGlobalPools);
}
/**
* A getter as well as a setter for those servers that use introspection
*/
public Boolean getCacheDestinations() {
return mcfProperties.isCacheDestinations();
}
public Boolean isCacheDestinations() {
return mcfProperties.isCacheDestinations();
}
@ -588,6 +642,13 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti
mcfProperties.setCacheDestinations(cacheDestinations);
}
/**
* A getter as well as a setter for those servers that use introspection
*/
public Boolean getEnable1xPrefixes() {
return mcfProperties.isEnable1xPrefixes();
}
public Boolean isEnable1xPrefixes() {
return mcfProperties.isEnable1xPrefixes();
}
@ -612,6 +673,13 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti
mcfProperties.setThreadPoolMaxSize(threadPoolMaxSize);
}
/**
* A getter as well as a setter for those servers that use introspection
*/
public Boolean getHA() {
return mcfProperties.isHA();
}
public Boolean isHA() {
return mcfProperties.isHA();
}
@ -620,10 +688,32 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti
mcfProperties.setAllowLocalTransactions(allowLocalTransactions);
}
/**
* A getter as well as a setter for those servers that use introspection
*/
public Boolean getAllowLocalTransactions() {
return mcfProperties.isAllowLocalTransactions();
}
public Boolean isAllowLocalTransactions() {
return mcfProperties.isAllowLocalTransactions();
}
/**
* A getter as well as a setter for those servers that use introspection
*/
public Boolean getInJtaTransaction() {
return mcfProperties.isInJtaTransaction();
}
public Boolean isInJtaTransaction() {
return mcfProperties.isInJtaTransaction();
}
public void setInJtaTransaction(Boolean inJtaTransaction) {
mcfProperties.setInJtaTransaction(inJtaTransaction);
}
public void setHA(Boolean ha) {
mcfProperties.setHA(ha);
}

View File

@ -816,7 +816,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon
//Both arguments {@code transacted} and {@code acknowledgeMode} are ignored.
// fix of ARTEMIS-1669 - when a JMSConnectionFactoryDefinition annotation with the transactional attribute set to false="false" is set
// then it should not be included in any JTA transaction and behave like that there is no JTA transaction.
if (!mcf.isIgnoreJTA() && inJtaTransaction()) {
if (!mcf.isIgnoreJTA() && (inJtaTransaction() || mcf.isInJtaTransaction())) {
transacted = true;
//from getAcknowledgeMode
// If the session is transacted, returns SESSION_TRANSACTED.

View File

@ -750,12 +750,15 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions {
return hasBeenUpdated;
}
/*
* This is here just for backward compatibility and not used
* */
public void setEnableSharedClientID(boolean enable) {
this.enableSharedClientID = enable;
}
public boolean isEnableSharedClientID() {
return enableSharedClientID;
return enableSharedClientID != null ? enableSharedClientID : false;
}
@Override

View File

@ -143,7 +143,8 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen
logger.trace("constructor()");
}
ra = null;
// we create an Adapter here but only for Application Servers that do introspection on loading to avoid an NPE
ra = new ActiveMQResourceAdapter();
destination = null;
destinationType = null;
messageSelector = null;

View File

@ -50,8 +50,12 @@ under the License.
<artifactId>artemis-jms-client</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
<groupId>jakarta.jms</groupId>
<artifactId>jakarta.jms-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
@ -63,11 +67,35 @@ under the License.
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-ra</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.jms</groupId>
<artifactId>jakarta.jms-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-server</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.jms</groupId>
<artifactId>jakarta.jms-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
@ -78,6 +106,10 @@ under the License.
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-core-client</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>

View File

@ -8,11 +8,10 @@
http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
version="1.5">
<description>ActiveMQ Artemis 2.0 Resource Adapter</description>
<display-name>ActiveMQ Artemis 2.0 Resource Adapter</display-name>
<display-name>ArtemisRA</display-name>
<description>ActiveMQ Artemis Resource Adapter</description>
<vendor-name>Apache Software Foundation</vendor-name>
<eis-type>JMS 1.1 Server</eis-type>
<eis-type>JMS 2.0 Server</eis-type>
<resourceadapter-version>1.0</resourceadapter-version>
<license>
@ -44,7 +43,7 @@
</description>
<config-property-name>ConnectorClassName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory</config-property-value>
<config-property-value>org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory</config-property-value>
</config-property>
<config-property>
<description>The transport configuration. These values must be in the form of key=val;key=val;,
@ -53,217 +52,182 @@
</description>
<config-property-name>ConnectionParameters</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>server-id=0</config-property-value>
<config-property-value>host=localhost,port=61616</config-property-value>
</config-property>
<!--
<config-property>
<!-- <config-property>
<description>Does we support HA</description>
<config-property-name>HA</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>false</config-property-value>
</config-property>
<config-property>
<description>The method to use for locating the transactionmanager</description>
<config-property-name>TransactionManagerLocatorMethod</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>getTm</config-property-value>
</config-property>
<config-property>
<description>Use A local Transaction instead of XA?</description>
<config-property-name>UseLocalTx</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>false</config-property-value>
</config-property>
<config-property>
<description>The user name used to login to the JMS server</description>
<config-property-name>UserName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The password used to login to the JMS server</description>
<config-property-name>Password</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The jndi params to use to look up the jms resources if local jndi is not to be used</description>
<config-property-name>JndiParams</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory;java.naming.provider.url=jnp://localhost:1199;java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces</config-property-value>
</config-property>
<config-property>
<description>The jGroups File name</description>
<config-property-name>JgroupsFile</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>jgroups.xml</config-property-value>
</config-property>
<config-property>
<description>The name of the channel used on this configuration</description>
<config-property-name>JgroupsChannelName</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value>my-channel</config-property-value>
</config-property>
<config-property>
<description>The discovery group address</description>
<config-property-name>DiscoveryAddress</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The discovery group port</description>
<config-property-name>DiscoveryPort</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The discovery refresh timeout</description>
<config-property-name>DiscoveryRefreshTimeout</config-property-name>
<config-property-type>java.lang.Long</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The discovery initial wait timeout</description>
<config-property-name>DiscoveryInitialWaitTimeout</config-property-name>
<config-property-type>java.lang.Long</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The load balancing policy class name</description>
<config-property-name>LoadBalancingPolicyClassName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The client failure check period</description>
<config-property-name>ClientFailureCheckPeriod</config-property-name>
<config-property-type>java.lang.Long</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The connection TTL</description>
<config-property-name>ConnectionTTL</config-property-name>
<config-property-type>java.lang.Long</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The call timeout</description>
<config-property-name>CallTimeout</config-property-name>
<config-property-type>java.lang.Long</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The dups ok batch size</description>
<config-property-name>DupsOKBatchSize</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The transaction batch size</description>
<config-property-name>TransactionBatchSize</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The consumer window size</description>
<config-property-name>ConsumerWindowSize</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The consumer max rate</description>
<config-property-name>ConsumerMaxRate</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The confirmation window size</description>
<config-property-name>ConfirmationWindowSize</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The producer max rate</description>
<config-property-name>ProducerMaxRate</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The min large message size</description>
<config-property-name>MinLargeMessageSize</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The block on acknowledge</description>
<config-property-name>BlockOnAcknowledge</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The block on non durable send</description>
<config-property-name>BlockOnNonDurableSend</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The block on durable send</description>
<config-property-name>BlockOnDurableSend</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The auto group</description>
<config-property-name>AutoGroup</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The max connections</description>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The pre acknowledge</description>
<config-property-name>PreAcknowledge</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The retry interval</description>
<config-property-name>RetryInterval</config-property-name>
<config-property-type>java.lang.Long</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The retry interval multiplier</description>
<config-property-name>RetryIntervalMultiplier</config-property-name>
<config-property-type>java.lang.Double</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The client id</description>
<config-property-name>ClientID</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>Whether the password is cleartext or encrypted, default false</description>
<config-property-name>UseMaskedPassword</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
<description>The class definition (full qualified name and its properties) used to encrypt the password</description>
<config-property-name>PasswordCodec</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec;key=clusterpassword;algorithm=something</config-property-value>
</config-property>
<config-property>
<description>Cache destinations per session</description>
<config-property-name>CacheDestinations</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>false</config-property-value>
</config-property>-->
<outbound-resourceadapter>
@ -276,6 +240,12 @@
<config-property-type>java.lang.String</config-property-type>
<config-property-value>javax.jms.Queue</config-property-value>
</config-property>
<config-property>
<description>Whether or not to participate in a JTA transaction, this is used if the RA does not have access to the Transaction Manager</description>
<config-property-name>InJtaTransaction</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
<config-property>
<description>Try to obtain a lock within specified number of seconds; less than or equal to 0 disable this functionality</description>
<config-property-name>UseTryLock</config-property-name>

View File

@ -93,7 +93,7 @@
<commons.io.version>2.9.0</commons.io.version>
<fuse.mqtt.client.version>1.16</fuse.mqtt.client.version>
<guava.version>30.1-jre</guava.version>
<jboss.logging.version>3.4.0.Final</jboss.logging.version>
<jboss.logging.version>3.4.2.Final</jboss.logging.version>
<jetty.version>9.4.40.v20210413</jetty.version>
<jgroups.version>3.6.13.Final</jgroups.version>
<errorprone.version>2.6.0</errorprone.version>