Java Code Examples for org.apache.activemq.broker.BrokerService#getTransportConnectors()
The following examples show how to use
org.apache.activemq.broker.BrokerService#getTransportConnectors() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiBrokersMultiClientsUsingTcpTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
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."); } }
Example 2
Source File: MulticastDiscoveryOnFaultyNetworkTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker, boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception { String networkDisoveryUrlString = useStaticDiscovery ? "static:(" + remoteBroker.getTransportConnectors().get(0).getPublishableConnectString() + ")?useExponentialBackOff=false" : "multicast://default?group=TESTERIC&useLocalHost=false"; DiscoveryNetworkConnector connector = new DiscoveryNetworkConnector(new URI(networkDisoveryUrlString)); connector.setDynamicOnly(dynamicOnly); connector.setNetworkTTL(networkTTL); connector.setDuplex(useDuplexNetworkBridge); maxSetupTime = 2000; if (!useStaticDiscovery) { List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors(); if (!transportConnectors.isEmpty()) { TransportConnector mCastTrpConnector = (transportConnectors.get(0)); mCastTrpConnector.setDiscoveryUri(new URI("multicast://default?group=TESTERIC")); } } localBroker.addNetworkConnector(connector); return connector; }
Example 3
Source File: ThreeBrokerStompTemporaryQueueTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker, boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception { List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors(); URI remoteURI; if (!transportConnectors.isEmpty()) { remoteURI = transportConnectors.get(0).getConnectUri(); NetworkConnector connector = new DiscoveryNetworkConnector(new URI("static:" + remoteURI)); connector.setName(localBroker.getBrokerName() + remoteBroker.getBrokerName()); localBroker.addNetworkConnector(connector); maxSetupTime = 2000; return connector; } else { throw new Exception("Remote broker has no registered connectors."); } }
Example 4
Source File: JmsMultipleBrokersTestSupport.java From activemq-artemis with Apache License 2.0 | 6 votes |
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); transport.setDiscoveryUri(new URI("multicast://default?group=" + groupName)); NetworkConnector nc = broker.addNetworkConnector("multicast://default?group=" + groupName); nc.setNetworkTTL(ttl); nc.setSuppressDuplicateQueueSubscriptions(suppressduplicateQueueSubs); nc.setDecreaseNetworkConsumerPriority(decreasePriority); } // Multicasting may take longer to setup maxSetupTime = 8000; }
Example 5
Source File: NetworkOfTwentyBrokersTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@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; }
Example 6
Source File: ThreeBrokerTopicNetworkUsingTcpTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
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."); } maxSetupTime = 2000; }
Example 7
Source File: ThreeBrokerQueueNetworkUsingTcpTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
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."); } maxSetupTime = 2000; }
Example 8
Source File: BrokerQueueNetworkWithDisconnectTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker, boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception { List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors(); URI remoteURI; if (!transportConnectors.isEmpty()) { remoteURI = transportConnectors.get(0).getConnectUri(); if (useSocketProxy) { socketProxy = new SocketProxy(remoteURI); remoteURI = socketProxy.getUrl(); } DiscoveryNetworkConnector connector = new DiscoveryNetworkConnector(new URI("static:(" + remoteURI + "?wireFormat.maxInactivityDuration=" + inactiveDuration + "&wireFormat.maxInactivityDurationInitalDelay=" + inactiveDuration + ")?useExponentialBackOff=false")); connector.setDynamicOnly(dynamicOnly); connector.setNetworkTTL(networkTTL); localBroker.addNetworkConnector(connector); maxSetupTime = 2000; if (useDuplexNetworkBridge) { connector.setDuplex(true); } return connector; } else { throw new Exception("Remote broker has no registered connectors."); } }
Example 9
Source File: JmsMultipleBrokersTestSupport.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker, boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception { List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors(); URI remoteURI; if (!transportConnectors.isEmpty()) { remoteURI = transportConnectors.get(0).getConnectUri(); String uri = "static:(" + remoteURI + ")"; if (failover) { uri = "static:(failover:(" + remoteURI + "))"; } NetworkConnector connector = new DiscoveryNetworkConnector(new URI(uri)); connector.setName("to-" + remoteBroker.getBrokerName()); connector.setDynamicOnly(dynamicOnly); connector.setNetworkTTL(networkTTL); connector.setConduitSubscriptions(conduit); localBroker.addNetworkConnector(connector); maxSetupTime = 2000; return connector; } else { throw new Exception("Remote broker has no registered connectors."); } }
Example 10
Source File: ActiveMQTestBase.java From vertx-proton with Apache License 2.0 | 5 votes |
public BrokerService restartBroker(BrokerService brokerService) throws Exception { String name = brokerService.getBrokerName(); Map<String, Integer> portMap = new HashMap<String, Integer>(); for (TransportConnector connector : brokerService.getTransportConnectors()) { portMap.put(connector.getName(), connector.getPublishableConnectURI().getPort()); } stopBroker(brokerService); BrokerService broker = createBroker(name, false, portMap); broker.start(); broker.waitUntilStarted(); return broker; }
Example 11
Source File: QpidJmsTestSupport.java From qpid-jms with Apache License 2.0 | 5 votes |
public BrokerService restartBroker(BrokerService brokerService) throws Exception { String name = brokerService.getBrokerName(); Map<String, Integer> portMap = new HashMap<String, Integer>(); for (TransportConnector connector : brokerService.getTransportConnectors()) { portMap.put(connector.getName(), connector.getPublishableConnectURI().getPort()); } stopBroker(brokerService); BrokerService broker = createBroker(name, false, portMap); broker.start(); broker.waitUntilStarted(); return broker; }
Example 12
Source File: OpenEjbBrokerFactoryTest.java From tomee with Apache License 2.0 | 5 votes |
private void stopBroker(final BrokerService broker) throws Exception { if (broker == null) return; if (broker.getJmsBridgeConnectors() != null) { for (final JmsConnector connector : broker.getJmsBridgeConnectors()) { connector.stop(); } } for (final Object o : broker.getTransportConnectors()) { final TransportConnector tc = (TransportConnector) o; tc.stop(); } broker.stop(); }
Example 13
Source File: DurableSubscriberWithNetworkDisconnectTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Override protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker, boolean l_dynamicOnly, int networkTTL, boolean l_conduit, boolean l_failover) throws Exception { List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors(); URI remoteURI; if (!transportConnectors.isEmpty()) { remoteURI = transportConnectors.get(0).getConnectUri(); if (useSocketProxy) { socketProxy = new SocketProxy(remoteURI); remoteURI = socketProxy.getUrl(); } String options = ""; if (failover) { options = "static:(failover:(" + remoteURI; } else { options = "static:(" + remoteURI; } if (inactivity) { options += "?wireFormat.maxInactivityDuration=" + inactiveDuration + "&wireFormat.maxInactivityDurationInitalDelay=" + inactiveDuration + ")"; } else { options += ")"; } if (failover) { options += "?maxReconnectAttempts=0)"; } options += "?useExponentialBackOff=" + exponentialBackOff; DiscoveryNetworkConnector connector = new DiscoveryNetworkConnector(new URI(options)); connector.setDynamicOnly(dynamicOnly); connector.setNetworkTTL(networkTTL); localBroker.addNetworkConnector(connector); maxSetupTime = 2000; if (useDuplexNetworkBridge) { connector.setDuplex(true); } return connector; } else { throw new Exception("Remote broker has no registered connectors."); } }