Search in sources :

Example 46 with TransportConnector

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.");
    }
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) NetworkBridgeConfiguration(org.apache.activemq.network.NetworkBridgeConfiguration) DemandForwardingBridge(org.apache.activemq.network.DemandForwardingBridge) URI(java.net.URI)

Example 47 with TransportConnector

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;
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) NetworkConnector(org.apache.activemq.network.NetworkConnector) BrokerService(org.apache.activemq.broker.BrokerService) URI(java.net.URI)

Example 48 with TransportConnector

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);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) TransportConnector(org.apache.activemq.broker.TransportConnector) PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry) Before(org.junit.Before)

Example 49 with TransportConnector

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);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) TransportConnector(org.apache.activemq.broker.TransportConnector) PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry) Before(org.junit.Before)

Example 50 with TransportConnector

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();
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) TransportConnector(org.apache.activemq.broker.TransportConnector) BrokerService(org.apache.activemq.broker.BrokerService)

Aggregations

TransportConnector (org.apache.activemq.broker.TransportConnector)59 URI (java.net.URI)31 BrokerService (org.apache.activemq.broker.BrokerService)31 NetworkConnector (org.apache.activemq.network.NetworkConnector)10 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)9 DiscoveryNetworkConnector (org.apache.activemq.network.DiscoveryNetworkConnector)7 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Connection (javax.jms.Connection)4 PolicyEntry (org.apache.activemq.broker.region.policy.PolicyEntry)4 PolicyMap (org.apache.activemq.broker.region.policy.PolicyMap)4 JMSException (javax.jms.JMSException)3 Session (javax.jms.Session)3 File (java.io.File)2 Principal (java.security.Principal)2 MessageProducer (javax.jms.MessageProducer)2 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)2 ConnectionContext (org.apache.activemq.broker.ConnectionContext)2 Connector (org.apache.activemq.broker.Connector)2 StubConnection (org.apache.activemq.broker.StubConnection)2