public TransportConfiguration newTransportConfig(String newName) { return new TransportConfiguration(factoryClassName, params, newName); }
@Override public final TransportConfiguration getConnectorConfig() { if (configuration != null) { return new TransportConfiguration(NettyConnectorFactory.class.getName(), this.configuration); } else { return null; } }
public static TransportConfiguration createTransportConfiguration(URI uri, Map<String, String> query, String name, String factoryName) { Map<String, Object> inVmTransportConfig = new HashMap<>(); inVmTransportConfig.put("serverId", uri.getHost()); if (query.containsKey(CONNECTIONS_ALLOWED)) { inVmTransportConfig.put(CONNECTIONS_ALLOWED, query.get(CONNECTIONS_ALLOWED)); } return new TransportConfiguration(factoryName, inVmTransportConfig, name); } }
public static List<TransportConfiguration> getTransportConfigurations(URI uri, Map<String, String> query, Set<String> allowableProperties, String name, String factoryName) throws URISyntaxException { HashMap<String, Object> props = new HashMap<>(); Map<String, Object> extraProps = new HashMap<>(); BeanSupport.setData(uri, props, allowableProperties, query, extraProps); List<TransportConfiguration> transportConfigurations = new ArrayList<>(); TransportConfiguration config = new TransportConfiguration(factoryName, props, name, extraProps); transportConfigurations.add(config); String connectors = uri.getFragment(); if (connectors != null && !connectors.trim().isEmpty()) { String[] split = connectors.split(","); for (String s : split) { URI extraUri = new URI(s); HashMap<String, Object> newProps = new HashMap<>(); extraProps = new HashMap<>(); BeanSupport.setData(extraUri, newProps, allowableProperties, query, extraProps); BeanSupport.setData(extraUri, newProps, allowableProperties, parseQuery(extraUri.getQuery(), null), extraProps); transportConfigurations.add(new TransportConfiguration(factoryName, newProps, name + ":" + extraUri.toString(), extraProps)); } } return transportConfigurations; }
/** * Replaces class name and parameter names to HornetQ values. */ 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 tc; }
/** * Adapt the transport configuration by replacing the factoryClassName corresponding to an HornetQ's NettyConnectorFactory * by the Artemis-based implementation. */ @Override public TransportConfiguration adaptTransportConfiguration(TransportConfiguration tc) { if (tc == null) { return null; } String factoryClassName = tc.getFactoryClassName(); if (factoryClassName.equals("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory")) { factoryClassName = NettyConnectorFactory.class.getName(); } TransportConfiguration newConfig = new TransportConfiguration(factoryClassName, tc.getParams(), tc.getName(), tc.getExtraParams()); return newConfig; }
TransportConfiguration connector = new TransportConfiguration();
@Override public void decodeRest(final ActiveMQBuffer buffer) { exit = buffer.readBoolean(); nodeID = buffer.readString(); if (!exit) { boolean hasLive = buffer.readBoolean(); TransportConfiguration a; if (hasLive) { a = new TransportConfiguration(); a.decode(buffer); } else { a = null; } boolean hasBackup = buffer.readBoolean(); TransportConfiguration b; if (hasBackup) { b = new TransportConfiguration(); b.decode(buffer); } else { b = null; } pair = new Pair<>(a, b); last = buffer.readBoolean(); } }
@Override public void decodeRest(final ActiveMQBuffer buffer) { exit = buffer.readBoolean(); nodeID = buffer.readString(); uniqueEventID = buffer.readLong(); if (!exit) { boolean hasLive = buffer.readBoolean(); TransportConfiguration a; if (hasLive) { a = new TransportConfiguration(); a.decode(buffer); } else { a = null; } boolean hasBackup = buffer.readBoolean(); TransportConfiguration b; if (hasBackup) { b = new TransportConfiguration(); b.decode(buffer); } else { b = null; } pair = new Pair<>(a, b); last = buffer.readBoolean(); } if (buffer.readableBytes() > 0) { backupGroupName = buffer.readNullableString(); } }
@Override public final TransportConfiguration getConnectorConfig() { if (configuration != null) { return new TransportConfiguration(NettyConnectorFactory.class.getName(), this.configuration); } else { return null; } }
static TransportConfiguration createTransportConfigiguration(boolean acceptor, int port) { String className; if (acceptor) { className = NettyAcceptorFactory.class.getName(); } else { className = NettyConnectorFactory.class.getName(); } Map<String, Object> serverParams = new HashMap<>(); serverParams.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, port); return new TransportConfiguration(className, serverParams); }
@Override protected TransportConfiguration getNettyAcceptorTransportConfiguration(final boolean live) { Map<String, Object> server1Params = new HashMap<>(); if (live) { server1Params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_PORT); server1Params.put(TransportConstants.HOST_PROP_NAME, LIVE_IP); } else { server1Params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_PORT); server1Params.put(TransportConstants.HOST_PROP_NAME, "localhost"); } return new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, server1Params); }
/** * Replaces class name and parameter names to HornetQ values. */ 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 tc; }
@Test public void testSameHostInVMTrue() { Map<String, Object> params1 = new HashMap<>(); params1.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, "blah"); TransportConfiguration tc1 = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params1); Map<String, Object> params2 = new HashMap<>(); params2.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, "blah"); TransportConfiguration tc2 = new TransportConfiguration(NettyConnectorFactory.class.getName(), params2); Assert.assertTrue(TransportConfigurationUtil.isSameHost(tc1, tc2)); }
@Test public void testToStringObfuscatesPasswords() { HashMap<String, Object> params = new HashMap<>(); params.put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, "secret_password"); params.put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, "secret_password"); TransportConfiguration configuration = new TransportConfiguration("SomeClass", params, null); Assert.assertThat(configuration.toString(), not(containsString("secret_password"))); }
private void createArtemisServer(String securityConfigScope) { ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(securityConfigScope); HashMap<String, Object> params = new HashMap<>(); params.put(TransportConstants.PORT_PROP_NAME, String.valueOf(5672)); params.put(TransportConstants.PROTOCOLS_PROP_NAME, "AMQP"); HashMap<String, Object> amqpParams = new HashMap<>(); amqpParams.put("saslMechanisms", "GSSAPI"); amqpParams.put("saslLoginConfigScope", "amqp-sasl-gssapi"); Configuration configuration = new ConfigurationImpl().setSecurityEnabled(true).addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params, "netty-amqp", amqpParams)).setJournalDirectory(ActiveMQTestBase.getJournalDir(testDir, 0, false)).setBindingsDirectory(ActiveMQTestBase.getBindingsDir(testDir, 0, false)).setPagingDirectory(ActiveMQTestBase.getPageDir(testDir, 0, false)).setLargeMessagesDirectory(ActiveMQTestBase.getLargeMessagesDir(testDir, 0, false)); server = ActiveMQServers.newActiveMQServer(configuration, ManagementFactory.getPlatformMBeanServer(), securityManager, false); }
@Before public void setup() throws Exception { server = createServer(true); server.start(); server.waitForActivation(10, TimeUnit.SECONDS); ServerLocator sl = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY)); sessionFactory = sl.createSessionFactory(); addSessionFactory(sessionFactory); }
@Override @Before public void setUp() throws Exception { super.setUp(); server = addServer(ActiveMQServers.newActiveMQServer(createDefaultInVMConfig(), false)); server.start(); cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY)); cf.setBlockOnDurableSend(true); cf.setPreAcknowledge(true); }
@Before public void setup() throws Exception { server = createServer(true); server.start(); server.waitForActivation(10, TimeUnit.SECONDS); ServerLocator sl = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY)); sessionFactory = sl.createSessionFactory(); addSessionFactory(sessionFactory); addressInfo = new AddressInfo(baseAddress); addressInfo.addRoutingType(RoutingType.MULTICAST); server.addOrUpdateAddressInfo(addressInfo); }
static Configuration createConfig(String folder) { AddressSettings settings = new AddressSettings().setMaxDeliveryAttempts(-1).setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE).setPageSizeBytes(10 * 1024).setMaxSizeBytes(100 * 1024); Configuration config = new ConfigurationImpl().setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(100 * 1024).setJournalType(ActiveMQTestBase.getDefaultJournalType()).setJournalCompactMinFiles(0).setJournalCompactPercentage(0).setClusterPassword(ActiveMQTestBase.CLUSTER_PASSWORD).setJournalDirectory(ActiveMQTestBase.getJournalDir(folder, 0, false)).setBindingsDirectory(ActiveMQTestBase.getBindingsDir(folder, 0, false)).setPagingDirectory(ActiveMQTestBase.getPageDir(folder, 0, false)).setLargeMessagesDirectory(ActiveMQTestBase.getLargeMessagesDir(folder, 0, false)).setPersistenceEnabled(true).addAddressesSetting("#", settings).addAcceptorConfiguration(new TransportConfiguration(ActiveMQTestBase.NETTY_ACCEPTOR_FACTORY)); return config; }