本文整理匯總了Java中org.apache.activemq.broker.BrokerService.setBrokerName方法的典型用法代碼示例。如果您正苦於以下問題:Java BrokerService.setBrokerName方法的具體用法?Java BrokerService.setBrokerName怎麽用?Java BrokerService.setBrokerName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.activemq.broker.BrokerService
的用法示例。
在下文中一共展示了BrokerService.setBrokerName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startBroker
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Before
public void startBroker() throws Exception {
broker = new BrokerService();
broker.setUseJmx(false);
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.addConnector(BROKER_URL);
broker.setBrokerName("localhost");
broker.setPopulateJMSXUserID(true);
broker.setUseAuthenticatedPrincipalForJMSXUserID(true);
// enable authentication
List<AuthenticationUser> users = new ArrayList<>();
// username and password to use to connect to the broker.
// This user has users privilege (able to browse, consume, produce, list destinations)
users.add(new AuthenticationUser(USERNAME, PASSWORD, "users"));
SimpleAuthenticationPlugin plugin = new SimpleAuthenticationPlugin(users);
BrokerPlugin[] plugins = new BrokerPlugin[]{ plugin };
broker.setPlugins(plugins);
broker.start();
// create JMS connection factory
connectionFactory = new ActiveMQConnectionFactory(BROKER_URL);
connectionFactoryWithoutPrefetch =
new ActiveMQConnectionFactory(BROKER_URL + "?jms.prefetchPolicy.all=0");
}
示例2: createBrokerService
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
private BrokerService createBrokerService(final String name) {
final BrokerService broker = new BrokerService();
broker.setPersistent(persistent);
broker.setBrokerName(name);
broker.setStartAsync(false);
tempDir = Files.createTempDir();
broker.setDataDirectoryFile(tempDir);
try {
broker.addConnector(createVmTransportServer(createVmTransportUri(name)));
} catch (Exception e) {
throw new IllegalStateException("Could not create VM Transport URI", e);
}
broker.setUseJmx(false);
return broker;
}
示例3: startMessagingSystem
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
private void startMessagingSystem()
{
try
{
brokerService = new BrokerService();
brokerService.addConnector(url+this.getApplicationPort2());
brokerService.setPersistent(false);
brokerService.setUseJmx(false);
brokerService.setBrokerName("MithraTest"+this.getApplicationPort2());
brokerService.setShutdownOnMasterFailure(false);
brokerService.start();
}
catch(Exception e)
{
getLogger().error("Unable to start messaging broker");
throw new RuntimeException("Exception during messaging broker startup", e);
}
}
示例4: startBroker
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
private boolean startBroker() {
try {
log.info("JMSServerController: Preparing to start JMS Broker: " );
broker = new BrokerService();
// configure the broker
broker.setBrokerName("myBroker1");
log.info(broker.getBrokerDataDirectory());
broker.setDataDirectory(System.getProperty(FrameworkConstants.CARBON_HOME) +
File.separator + broker.getBrokerDataDirectory());
broker.setTransportConnectors(getTCPConnectors());
broker.setPersistent(true);
broker.start();
log.info("JMSServerController: Broker is Successfully started. continuing tests");
return true;
} catch (Exception e) {
log.error(
"JMSServerController: There was an error starting JMS broker: ", e);
return false;
}
}
示例5: configureBroker
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
private BrokerService configureBroker(String brokerName) throws Exception {
BrokerService broker = new BrokerService();
broker.setBrokerName(brokerName);
broker.setAdvisorySupport(false);
broker.setPersistent(false);
broker.setUseJmx(false);
broker.setSchedulePeriodForDestinationPurge(1000);
broker.setAllowTempAutoCreationOnSend(true);
PolicyMap map = new PolicyMap();
PolicyEntry tempReplyQPolicy = new PolicyEntry();
tempReplyQPolicy.setOptimizedDispatch(true);
tempReplyQPolicy.setGcInactiveDestinations(true);
tempReplyQPolicy.setGcWithNetworkConsumers(true);
tempReplyQPolicy.setInactiveTimeoutBeforeGC(1000);
map.put(replyQWildcard, tempReplyQPolicy);
broker.setDestinationPolicy(map);
broker.addConnector("tcp://localhost:0");
brokers.add(broker);
return broker;
}
示例6: createBroker
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Override
protected BrokerService createBroker() throws Exception {
BrokerService service = new BrokerService();
service.setBrokerName("broker1");
service.setPersistent(false);
service.setUseJmx(false);
connector = service.addConnector(getLocalURI());
proxyConnector = new ProxyConnector();
proxyConnector.setName("proxy");
proxyConnector.setBind(new URI(getLocalProxyURI()));
proxyConnector.setRemote(new URI("fanout:static://" + getRemoteURI()));
service.addProxyConnector(proxyConnector);
return service;
}
示例7: createBroker
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
protected BrokerService createBroker() throws Exception {
localBroker = new BrokerService();
localBroker.setBrokerName("localhost");
localBroker.setUseJmx(true);
localBroker.setPersistenceAdapter(null);
localBroker.setPersistent(false);
connector = createConnector();
localBroker.addConnector(connector);
configureBroker(localBroker);
localBroker.start();
localBroker.waitUntilStarted();
localBroker.getManagementContext().setConnectorPort(2221);
brokers.put(localBroker.getBrokerName(), localBroker);
return localBroker;
}
示例8: createMaster
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Override
protected void createMaster() throws Exception {
master = new BrokerService();
master.setBrokerName("master");
master.addConnector(MASTER_URL);
master.setUseJmx(false);
master.setPersistent(true);
master.setDeleteAllMessagesOnStartup(true);
KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) master.getPersistenceAdapter();
LeaseDatabaseLocker leaseDatabaseLocker = new LeaseDatabaseLocker();
leaseDatabaseLocker.setCreateTablesOnStartup(true);
leaseDatabaseLocker.setDataSource(getExistingDataSource());
leaseDatabaseLocker.setStatements(new Statements());
kahaDBPersistenceAdapter.setLocker(leaseDatabaseLocker);
configureLocker(kahaDBPersistenceAdapter);
configureBroker(master);
master.start();
}
示例9: startBroker
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
private void startBroker(boolean deleteMessages) throws Exception {
broker = new BrokerService();
broker.setBrokerName("test-broker");
if (deleteMessages) {
broker.setDeleteAllMessagesOnStartup(true);
}
setDefaultPersistenceAdapter(broker);
/* use maxPageSize policy in place of always pulling from the broker in maxRows chunks
if (broker.getPersistenceAdapter() instanceof JDBCPersistenceAdapter) {
((JDBCPersistenceAdapter)broker.getPersistenceAdapter()).setMaxRows(5000);
}*/
PolicyMap policyMap = new PolicyMap();
PolicyEntry defaultEntry = new PolicyEntry();
defaultEntry.setMaxPageSize(5000);
policyMap.setDefaultEntry(defaultEntry);
broker.setDestinationPolicy(policyMap);
broker.start();
}
示例10: configureBroker
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
protected void configureBroker(BrokerService brokerService) throws Exception {
brokerService.setBrokerName("testbroker1");
brokerService.setUseJmx(false);
brokerService.setPersistent(false);
brokerService.setAdvisorySupport(false);
brokerService.setSchedulerSupport(false);
TransportConnector connector = new TransportConnector();
connector.setUri(new URI("tcp://localhost:0"));
connector.setName(testName.getMethodName());
brokerService.addConnector(connector);
}
示例11: createBroker
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Override
protected String createBroker() throws Exception {
brokerService = new BrokerService();
brokerService.setBrokerName("PooledConnectionSessionCleanupTestBroker");
brokerService.setUseJmx(true);
brokerService.getManagementContext().setCreateConnector(false);
brokerService.setPersistent(false);
brokerService.setSchedulerSupport(false);
brokerService.setAdvisorySupport(false);
TransportConnector connector = brokerService.addConnector("tcp://0.0.0.0:61626");
brokerService.start();
brokerService.waitUntilStarted();
return "failover:(" + connector.getPublishableConnectString() + ")?maxReconnectAttempts=5";
}
示例12: setUp
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
/**
* Prepare to run a test case: create, configure, and start the embedded
* broker, as well as creating the client connections to the broker.
*/
@Override
@Before
public void setUp() throws java.lang.Exception {
super.setUp();
brokerService = new BrokerService();
brokerService.setBrokerName("PooledConnectionSessionCleanupTestBroker");
brokerService.setUseJmx(true);
brokerService.getManagementContext().setCreateConnector(false);
brokerService.setPersistent(false);
brokerService.setSchedulerSupport(false);
brokerService.setAdvisorySupport(false);
brokerService.start();
brokerService.waitUntilStarted();
// Create the ActiveMQConnectionFactory and the JmsPoolConnectionFactory.
// Set a long idle timeout on the pooled connections to better show the
// problem of holding onto created resources on close.
directConnFact = new ActiveMQConnectionFactory(brokerService.getVmConnectorURI());
pooledConnFact = new JmsPoolConnectionFactory();
pooledConnFact.setConnectionFactory(directConnFact);
pooledConnFact.setIdleTimeout((int)TimeUnit.MINUTES.toMillis(60));
pooledConnFact.setMaxConnections(1);
// Prepare the connections
directConn1 = directConnFact.createConnection();
directConn1.start();
directConn2 = directConnFact.createConnection();
directConn2.start();
// The pooled Connections should have the same underlying connection
pooledConn1 = pooledConnFact.createConnection();
pooledConn1.start();
pooledConn2 = pooledConnFact.createConnection();
pooledConn2.start();
}
示例13: setupBroker
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
private BrokerService setupBroker(int thisPort, int otherPort) throws Exception {
BrokerService broker = new BrokerService();
broker.setPersistent(false);
broker.setBrokerName("broker" + thisPort);
broker.addConnector("tcp://0.0.0.0:" + thisPort);
broker.addNetworkConnector(String.format("static:(tcp://localhost:%d)", otherPort));
broker.start();
broker.waitUntilStarted();
return broker;
}
示例14: main
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
// BrokerService broker =BrokerFactory.createBroker(new URI("broker:tcp://localhost:61616"));
BrokerService broker =new BrokerService();
broker.setBrokerName("TestBroker"); // 如果啟動多個Broker時,必須為Broker設置一個名稱
broker.addConnector("tcp://127.0.0.1:61616");
broker.start();
}
示例15: setInitialConfigurations
import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
/**
* Helper method to set initial broker configurations.
*
* @throws Exception if there is an error setting TransportConnectors
*/
private void setInitialConfigurations() throws Exception {
log.info("JMSServerController: Preparing to start JMS Broker: " + serverName);
broker = new BrokerService();
broker.setBrokerName(serverName);
log.info(broker.getBrokerDataDirectory());
broker.setDataDirectory(System.getProperty(FrameworkConstants.CARBON_HOME) + File.separator
+ broker.getBrokerDataDirectory());
broker.setTransportConnectors(transportConnectors);
broker.setPersistent(true);
}