use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.
the class MultiBrokersMultiClientsUsingTcpTest method bridgeBrokers.
protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws Exception {
List<TransportConnector> remoteTransports = remoteBroker.getTransportConnectors();
List<TransportConnector> localTransports = localBroker.getTransportConnectors();
URI remoteURI;
URI localURI;
if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) {
remoteURI = remoteTransports.get(0).getConnectUri();
localURI = localTransports.get(0).getConnectUri();
// Ensure that we are connecting using tcp
if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:")) {
NetworkBridgeConfiguration config = new NetworkBridgeConfiguration();
config.setBrokerName(localBroker.getBrokerName());
DemandForwardingBridge bridge = new DemandForwardingBridge(config, TransportFactory.connect(localURI), TransportFactory.connect(remoteURI));
bridge.setBrokerService(localBroker);
bridges.add(bridge);
bridge.start();
} else {
throw new Exception("Remote broker or local broker is not using tcp connectors");
}
} else {
throw new Exception("Remote broker or local broker has no registered connectors.");
}
}
use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.
the class NetworkOfTwentyBrokersTest method bridgeAllBrokers.
@Override
protected void bridgeAllBrokers(String groupName, int ttl, boolean suppressduplicateQueueSubs, boolean decreasePriority) throws Exception {
Collection<BrokerItem> brokerList = brokers.values();
for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
BrokerService broker = i.next().broker;
List<TransportConnector> transportConnectors = broker.getTransportConnectors();
if (transportConnectors.isEmpty()) {
broker.addConnector(new URI(AUTO_ASSIGN_TRANSPORT));
transportConnectors = broker.getTransportConnectors();
}
TransportConnector transport = transportConnectors.get(0);
if (transport.getDiscoveryUri() == null) {
transport.setDiscoveryUri(new URI("multicast://default?group=" + groupName));
}
List<NetworkConnector> networkConnectors = broker.getNetworkConnectors();
if (networkConnectors.isEmpty()) {
broker.addNetworkConnector("multicast://default?group=" + groupName);
networkConnectors = broker.getNetworkConnectors();
}
NetworkConnector nc = networkConnectors.get(0);
nc.setNetworkTTL(ttl);
nc.setSuppressDuplicateQueueSubscriptions(suppressduplicateQueueSubs);
nc.setDecreaseNetworkConsumerPriority(decreasePriority);
}
// Multicasting may take longer to setup
maxSetupTime = 8000;
}
use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.
the class QueueBrowsingTest method startBroker.
@Before
public void startBroker() throws Exception {
broker = createBroker();
TransportConnector connector = broker.addConnector("tcp://0.0.0.0:0");
broker.deleteAllMessages();
broker.start();
broker.waitUntilStarted();
PolicyEntry policy = new PolicyEntry();
policy.setMaxPageSize(maxPageSize);
broker.setDestinationPolicy(new PolicyMap());
broker.getDestinationPolicy().setDefaultEntry(policy);
connectUri = connector.getConnectUri();
factory = new ActiveMQConnectionFactory(connectUri);
}
use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.
the class QueueBrowsingLimitTest method startBroker.
@Before
public void startBroker() throws Exception {
broker = createBroker();
TransportConnector connector = broker.addConnector("tcp://0.0.0.0:0");
broker.deleteAllMessages();
broker.start();
broker.waitUntilStarted();
PolicyEntry policy = new PolicyEntry();
policy.setMaxBrowsePageSize(browserLimit);
broker.setDestinationPolicy(new PolicyMap());
broker.getDestinationPolicy().setDefaultEntry(policy);
connectUri = connector.getConnectUri();
factory = new ActiveMQConnectionFactory(connectUri);
}
use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.
the class NIOSSLConcurrencyTest method setUp.
@Override
protected void setUp() throws Exception {
System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE);
System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD);
System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE);
System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE);
System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE);
System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD);
broker = new BrokerService();
broker.setPersistent(false);
broker.setUseJmx(false);
TransportConnector connector = broker.addConnector("nio+ssl://localhost:0?transport.needClientAuth=true&transport.enabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA");
broker.start();
broker.waitUntilStarted();
failed = false;
messageData = new byte[MESSAGE_SIZE];
for (int i = 0; i < MESSAGE_SIZE; i++) {
messageData[i] = (byte) (i & 0xff);
}
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("nio+ssl://localhost:" + connector.getConnectUri().getPort());
connection = factory.createConnection();
for (int i = 0; i < PRODUCER_COUNT; i++) {
producerSessions[i] = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
for (int i = 0; i < CONSUMER_COUNT; i++) {
consumerSessions[i] = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
connection.start();
}
Aggregations