mirror of
https://github.com/apache/activemq-artemis.git
synced 2025-02-21 01:15:50 +00:00
[ARTEMIS-3756]: Enabling extra parameters to be passed by the URI.
* passing the full list of parameters when creating the URI. * moving the WARN message to DEBUG when unknown parameters are received. Jira: https://issues.apache.org/jira/browse/ARTEMIS-3756
This commit is contained in:
parent
650952ba67
commit
52a4157bbb
@ -425,11 +425,6 @@ public interface ActiveMQClientLogger extends BasicLogger {
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void broadcastTimeout(int retry, int maxretry);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 212078, value = "Connection factory parameter ignored {0}",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void connectionFactoryParameterIgnored(String parameterName);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 212079, value = "The upstream connector from the downstream federation will ignore url parameter {0}", format = Message.Format.MESSAGE_FORMAT)
|
||||
void ignoredParameterForDownstreamFederation(String name);
|
||||
|
@ -279,7 +279,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
|
||||
// to create a connector just to validate if the parameters are ok.
|
||||
// so this will create the instance to be used on the isEquivalent check
|
||||
if (localConnector == null) {
|
||||
localConnector = connectorFactory.createConnector(currentConnectorConfig.getParams(), new DelegatingBufferHandler(), this, closeExecutor, threadPool, scheduledThreadPool, clientProtocolManager);
|
||||
localConnector = connectorFactory.createConnector(currentConnectorConfig.getCombinedParams(), new DelegatingBufferHandler(), this, closeExecutor, threadPool, scheduledThreadPool, clientProtocolManager);
|
||||
}
|
||||
|
||||
if (localConnector.isEquivalent(live.getParams()) && backUp != null && !localConnector.isEquivalent(backUp.getParams())
|
||||
@ -1127,7 +1127,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
|
||||
}
|
||||
|
||||
protected Connector createConnector(ConnectorFactory connectorFactory, TransportConfiguration configuration) {
|
||||
Connector connector = connectorFactory.createConnector(configuration.getParams(), new DelegatingBufferHandler(), this, closeExecutor, threadPool, scheduledThreadPool, clientProtocolManager);
|
||||
Connector connector = connectorFactory.createConnector(configuration.getCombinedParams(), new DelegatingBufferHandler(), this, closeExecutor, threadPool, scheduledThreadPool, clientProtocolManager);
|
||||
if (connector instanceof NettyConnector) {
|
||||
NettyConnector nettyConnector = (NettyConnector) connector;
|
||||
if (nettyConnector.getConnectTimeoutMillis() < 0) {
|
||||
|
@ -174,7 +174,7 @@ public class BackwardsCompatibilityUtils {
|
||||
private static TransportConfiguration convertTransport(TransportConfiguration tc) {
|
||||
if (tc != null) {
|
||||
String className = tc.getFactoryClassName().replace("org.apache.activemq.artemis", "org.hornetq").replace("ActiveMQ", "HornetQ");
|
||||
return new TransportConfiguration(className, convertParameters(tc.getParams()), tc.getName());
|
||||
return new TransportConfiguration(className, convertParameters(tc.getParams()), tc.getName(), convertParameters(tc.getExtraParams()));
|
||||
}
|
||||
return tc;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class TCPServerLocatorSchema extends AbstractServerLocatorSchema {
|
||||
StringBuilder fragment = new StringBuilder();
|
||||
for (int i = 1; i < staticConnectors.length; i++) {
|
||||
TransportConfiguration connector = staticConnectors[i];
|
||||
Map<String, Object> params = escapeIPv6Host(connector.getParams());
|
||||
Map<String, Object> params = escapeIPv6Host(connector.getCombinedParams());
|
||||
URI extraUri = new URI(SchemaConstants.TCP, null, getHost(params), getPort(params), null, createQuery(params, null), null);
|
||||
if (i > 1) {
|
||||
fragment.append(",");
|
||||
@ -74,7 +74,7 @@ public class TCPServerLocatorSchema extends AbstractServerLocatorSchema {
|
||||
fragment.append(extraUri.toASCIIString());
|
||||
|
||||
}
|
||||
Map<String, Object> params = escapeIPv6Host(staticConnectors[0].getParams());
|
||||
Map<String, Object> params = escapeIPv6Host(staticConnectors[0].getCombinedParams());
|
||||
return new URI(SchemaConstants.TCP, null, getHost(params), getPort(params), null, createQuery(params, query), fragment.toString());
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ import java.util.Properties;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.core.client.ActiveMQClientLogger;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
@ -31,9 +30,12 @@ import org.apache.activemq.artemis.uri.schema.connector.TCPTransportConfiguratio
|
||||
import org.apache.activemq.artemis.uri.schema.serverLocator.TCPServerLocatorSchema;
|
||||
import org.apache.activemq.artemis.utils.uri.BeanSupport;
|
||||
import org.apache.activemq.artemis.utils.uri.SchemaConstants;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
public class TCPSchema extends AbstractCFSchema {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TCPSchema.class);
|
||||
|
||||
@Override
|
||||
public String getSchemaName() {
|
||||
return SchemaConstants.TCP;
|
||||
@ -83,7 +85,7 @@ public class TCPSchema extends AbstractCFSchema {
|
||||
if (!key.equals("ha") && !key.equals("type") &&
|
||||
!TransportConstants.ALLOWABLE_CONNECTOR_KEYS.contains(key) &&
|
||||
!factoryProperties.containsKey(key)) {
|
||||
ActiveMQClientLogger.LOGGER.connectionFactoryParameterIgnored(key);
|
||||
logger.debugf("Connection factory parameter %s is not standard", key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -445,12 +445,18 @@ public class CoreProtocolManager implements ProtocolManager<Interceptor, ActiveM
|
||||
//Initialize the upstream transport with the config from the acceptor as this will apply
|
||||
//relevant settings such as SSL, then override with settings from the downstream config
|
||||
final Map<String, Object> params = new HashMap<>(acceptorUsed.getConfiguration());
|
||||
params.putAll(upstreamConfig.getParams());
|
||||
if (upstreamConfig.getParams() != null) {
|
||||
params.putAll(upstreamConfig.getParams());
|
||||
}
|
||||
final Map<String, Object> extraParams = new HashMap<>();
|
||||
if (upstreamConfig.getExtraParams() != null) {
|
||||
extraParams.putAll(upstreamConfig.getExtraParams());
|
||||
}
|
||||
|
||||
//Add the new upstream configuration that was created so we can connect back to the downstream server
|
||||
final TransportConfiguration upstreamConf = new TransportConfiguration(
|
||||
upstreamConfig.getFactoryClassName(), params, upstreamConfig.getName() + FederationDownstreamConnectMessage.UPSTREAM_SUFFIX,
|
||||
new HashMap<>());
|
||||
extraParams);
|
||||
server.getConfiguration()
|
||||
.addConnectorConfiguration(upstreamConf.getName() + FederationDownstreamConnectMessage.UPSTREAM_SUFFIX, upstreamConf);
|
||||
|
||||
|
@ -168,7 +168,7 @@ public class BackupActivationNoReconnectTest {
|
||||
when(connectorConfig.getFactoryClassName()).thenReturn(NettyConnectorFactory.class.getName());
|
||||
Map<String, Object> urlParams = new HashMap<>();
|
||||
urlParams.put("port", serverSocket.getLocalPort());
|
||||
when(connectorConfig.getParams()).thenReturn(urlParams);
|
||||
when(connectorConfig.getCombinedParams()).thenReturn(urlParams);
|
||||
ClientSessionFactoryImpl sessionFactory = new ClientSessionFactoryImpl(serverLocator, connectorConfig, locatorConfig, reconnectAttempts, threadPool, scheduledThreadPool, null, null);
|
||||
when(clusterControl.getSessionFactory()).thenReturn(sessionFactory);
|
||||
when(clientProtocolManager.isAlive()).thenReturn(true);
|
||||
|
@ -17,13 +17,14 @@
|
||||
|
||||
# Additional logger names to configure (root logger is always configured)
|
||||
# Root logger option
|
||||
loggers=org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.core.journal,org.apache.activemq.artemis.jms,org.apache.activemq.artemis.ra,org.apache.activemq.artemis.tests.smoke,org.apache.activemq.artemis.tests.unit,org.apache.activemq.artemis.tests.integration,org.apache.activemq.artemis.jms.tests,org.apache.activemq.cli.test,org.apache.activemq.audit,org.apache.activemq.audit.message
|
||||
loggers=org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.core.journal,org.apache.activemq.artemis.core.client,org.apache.activemq.artemis.jms,org.apache.activemq.artemis.ra,org.apache.activemq.artemis.tests.smoke,org.apache.activemq.artemis.tests.unit,org.apache.activemq.artemis.tests.integration,org.apache.activemq.artemis.jms.tests,org.apache.activemq.cli.test,org.apache.activemq.audit,org.apache.activemq.audit.message
|
||||
|
||||
# Root logger level
|
||||
logger.level=INFO
|
||||
# ActiveMQ Artemis logger levels
|
||||
logger.org.apache.activemq.artemis.core.server.level=INFO
|
||||
logger.org.apache.activemq.artemis.core.journal.level=INFO
|
||||
logger.org.apache.activemq.artemis.core.client.level=INFO
|
||||
logger.org.apache.activemq.artemis.utils.level=INFO
|
||||
logger.org.apache.activemq.artemis.jms.level=INFO
|
||||
logger.org.apache.activemq.artemis.ra.level=INFO
|
||||
|
@ -36,6 +36,7 @@ import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.BroadcastEndpoint;
|
||||
@ -59,6 +60,7 @@ import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
|
||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.utils.Wait;
|
||||
import org.jboss.logmanager.LogManager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -89,6 +91,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
|
||||
ctx.lookup("TCPConnectionFactory");
|
||||
ctx.lookup("UDPConnectionFactory");
|
||||
ctx.lookup("JGroupsConnectionFactory");
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -101,6 +104,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
|
||||
ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
|
||||
|
||||
connectionFactory.createConnection().close();
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -111,22 +115,26 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
|
||||
|
||||
//IIB v10 assumes this property is mandatory and sets it to an empty string when not specified
|
||||
props.put("java.naming.provider.url", "");
|
||||
new InitialContext(props);//Must not throw an exception
|
||||
|
||||
Context ctx = new InitialContext(props);//Must not throw an exception
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectionFactoryStringWithInvalidParameter() throws Exception {
|
||||
Level initialLevel = LogManager.getLogManager().getLogger("org.apache.activemq.artemis.core.client").getLevel();
|
||||
LogManager.getLogManager().getLogger("org.apache.activemq.artemis.core.client").setLevel(Level.ALL);
|
||||
Hashtable<String, String> props = new Hashtable<>();
|
||||
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
|
||||
props.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616?foo=too");
|
||||
|
||||
AssertionLoggerHandler.startCapture();
|
||||
try {
|
||||
new InitialContext(props);
|
||||
assertTrue("Expected to find AMQ212078", AssertionLoggerHandler.findText("AMQ212078"));
|
||||
Context ctx = new InitialContext(props);
|
||||
ctx.close();
|
||||
assertTrue("Connection factory parameter foo is not standard", AssertionLoggerHandler.findText("Connection factory parameter foo is not standard"));
|
||||
} finally {
|
||||
AssertionLoggerHandler.stopCapture();
|
||||
LogManager.getLogManager().getLogger("org.apache.activemq.artemis.core.client").setLevel(initialLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,6 +275,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
|
||||
ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("myConnectionFactory");
|
||||
|
||||
connectionFactory.createConnection().close();
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -292,6 +301,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
|
||||
Assert.assertNotEquals(1198, udpBroadcastEndpointFactory.getLocalBindPort());
|
||||
Assert.assertEquals(getUDPDiscoveryAddress(), udpBroadcastEndpointFactory.getGroupAddress());
|
||||
Assert.assertEquals(getUDPDiscoveryPort(), udpBroadcastEndpointFactory.getGroupPort());
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -304,6 +314,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
|
||||
ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("myConnectionFactory");
|
||||
|
||||
connectionFactory.createConnection().close();
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -379,6 +390,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
|
||||
Assert.assertEquals(parametersFromJNDI.get(ActiveMQDefaultConfiguration.getPropMaskPassword()), "myPropMaskPassword");
|
||||
Assert.assertEquals(parametersFromJNDI.get(ActiveMQDefaultConfiguration.getPropPasswordCodec()), "myPropPasswordCodec");
|
||||
Assert.assertEquals(parametersFromJNDI.get(TransportConstants.NETTY_CONNECT_TIMEOUT), "myNettyConnectTimeout");
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user