use of org.apache.activemq.broker.TransportConnector in project vcell by virtualcell.
the class ActiveMqTest method main.
/**
* @param args
*/
public static void main(String[] args) {
try {
BrokerService broker = new BrokerService();
broker.setBrokerName("fred");
broker.setUseShutdownHook(false);
broker.setPersistent(false);
// Add plugin
// broker.setPlugins(new BrokerPlugin[]{new JaasAuthenticationPlugin()});
// Add a network connection
NetworkConnector connector = broker.addNetworkConnector("static://" + "tcp://localhost:61616");
connector.setDuplex(true);
TransportConnector transportConnector = broker.addConnector("tcp://localhost:61616");
broker.start();
// transportConnector.
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.
the class JmsMultipleBrokersTestSupport method bridgeAllBrokers.
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;
}
use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.
the class FailoverStaticNetworkTest method createBroker.
protected BrokerService createBroker(String scheme, String listenPort, String[] networkToPorts, HashMap<String, String> networkProps) throws Exception {
BrokerService broker = new BrokerService();
broker.getManagementContext().setCreateConnector(false);
broker.setSslContext(sslContext);
broker.setDeleteAllMessagesOnStartup(true);
broker.setBrokerName("Broker_" + listenPort);
// lazy init listener on broker start
TransportConnector transportConnector = new TransportConnector();
transportConnector.setUri(new URI(scheme + "://localhost:" + listenPort));
List<TransportConnector> transportConnectors = new ArrayList<>();
transportConnectors.add(transportConnector);
broker.setTransportConnectors(transportConnectors);
if (networkToPorts != null && networkToPorts.length > 0) {
StringBuilder builder = new StringBuilder("static:(failover:(" + scheme + "://localhost:");
builder.append(networkToPorts[0]);
for (int i = 1; i < networkToPorts.length; i++) {
builder.append("," + scheme + "://localhost:" + networkToPorts[i]);
}
// limit the reconnects in case of initial random connection to slave
// leaving randomize on verifies that this config is picked up
builder.append(")?maxReconnectAttempts=0)?useExponentialBackOff=false");
NetworkConnector nc = broker.addNetworkConnector(builder.toString());
if (networkProps != null) {
IntrospectionSupport.setProperties(nc, networkProps);
}
}
return broker;
}
use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.
the class FailoverStaticNetworkTest method createBroker.
private BrokerService createBroker(String listenPort, String dataDir) throws Exception {
BrokerService broker = new BrokerService();
broker.setUseJmx(false);
broker.getManagementContext().setCreateConnector(false);
broker.setBrokerName("Broker_Shared");
// lazy create transport connector on start completion
TransportConnector connector = new TransportConnector();
connector.setUri(new URI("tcp://localhost:" + listenPort));
broker.addConnector(connector);
broker.setDataDirectory(dataDir);
return broker;
}
use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.
the class MQTTNetworkOfBrokersFailoverTest method createBroker.
@Override
protected BrokerService createBroker() throws Exception {
BrokerService broker = super.createBroker();
broker.setPersistent(true);
broker.setBrokerName("local");
broker.setDataDirectory("target/activemq-data");
broker.setDeleteAllMessagesOnStartup(true);
TransportConnector tc = broker.addConnector(getDefaultMQTTTransportConnectorUri());
localBrokerMQTTPort = tc.getConnectUri().getPort();
return broker;
}
Aggregations