本文整理汇总了Java中org.apache.activemq.broker.BrokerFactory.createBroker方法的典型用法代码示例。如果您正苦于以下问题:Java BrokerFactory.createBroker方法的具体用法?Java BrokerFactory.createBroker怎么用?Java BrokerFactory.createBroker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.broker.BrokerFactory
的用法示例。
在下文中一共展示了BrokerFactory.createBroker方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBroker
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
protected BrokerService createBroker() throws JMSException {
BrokerService broker = null;
try {
broker = BrokerFactory.createBroker(new URI("broker://()/localhost"));
broker.setBrokerName("DefaultBroker");
broker.addConnector("tcp://localhost:9100");
broker.setUseShutdownHook(false);
broker.start();
} catch (Exception e) {
e.printStackTrace();
}
return broker;
}
示例2: createBroker
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
@Override
// TODO throw corresponding exceptions, not just Exception instances.
protected BrokerService createBroker(ServletContext sc) throws Exception {
// Initialize Web environment to make Spring resolve external
// properties.
StandardServletEnvironment standardServletEnvironment = new ReversePropertySourcesStandardServletEnvironment();
WebApplicationContextUtils.initServletPropertySources(standardServletEnvironment.getPropertySources(), sc);
URI configURI = new URI(standardServletEnvironment.getProperty(BROKER_URI_PROP));
LOG.info("Loading message broker from: " + configURI);
return BrokerFactory.createBroker(configURI);
}
示例3: createBroker
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
private void createBroker(boolean deleteAllMessages) throws Exception {
broker = BrokerFactory.createBroker("broker:(vm://" + getName(true) + ")");
broker.setBrokerName(getName(true));
broker.setDeleteAllMessagesOnStartup(deleteAllMessages);
broker.setAdvisorySupport(false);
broker.addConnector("tcp://0.0.0.0:0");
setDefaultPersistenceAdapter(broker);
broker.start();
}
示例4: createBroker
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
private void createBroker(boolean deleteAllMessages) throws Exception {
broker = BrokerFactory.createBroker("broker:(vm://" + getName(true) + ")");
broker.setBrokerName(getName(true));
broker.setDeleteAllMessagesOnStartup(deleteAllMessages);
broker.getManagementContext().setCreateConnector(false);
broker.setAdvisorySupport(false);
broker.addConnector("tcp://0.0.0.0:0");
setDefaultPersistenceAdapter(broker);
((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).getStore().getPageFile().setPageSize(1024);
broker.start();
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:15,代码来源:DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.java
示例5: startBroker
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
private void startBroker() throws Exception {
broker = BrokerFactory.createBroker("broker:(vm://localhost)");
broker.setKeepDurableSubsActive(false);
broker.setPersistent(true);
LevelDBStore persistenceAdapter = new LevelDBStore();
persistenceAdapter.setDirectory(new File("activemq-data/" + getName()));
broker.setPersistenceAdapter(persistenceAdapter);
broker.setUseJmx(true);
broker.getManagementContext().setCreateConnector(false);
broker.setBrokerName(getName());
broker.start();
connection = createConnection();
}
示例6: createBroker
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
private void createBroker(boolean deleteAllMessages) throws Exception {
broker = BrokerFactory.createBroker("broker:(vm://" + getName(true) + ")");
broker.setBrokerName(getName(true));
broker.setDeleteAllMessagesOnStartup(deleteAllMessages);
broker.getManagementContext().setCreateConnector(false);
broker.setAdvisorySupport(false);
broker.addConnector("tcp://0.0.0.0:0");
setDefaultPersistenceAdapter(broker);
broker.start();
}
示例7: startBroker
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
private void startBroker() throws Exception {
brokerService = BrokerFactory.createBroker("broker:()/localhost?deleteAllMessagesOnStartup=true");
PolicyMap policyMap = new PolicyMap();
PolicyEntry policyEntry = new PolicyEntry();
policyEntry.setExpireMessagesPeriod(1000);
policyMap.setDefaultEntry(policyEntry);
brokerService.setDestinationPolicy(policyMap);
brokerService.start();
brokerService.waitUntilStarted();
}
示例8: testCloseSendConnection
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
public void testCloseSendConnection() throws Exception {
String brokerName = "closeSend";
BrokerService broker = BrokerFactory.createBroker(new URI("broker:(tcp://localhost:0)/" + brokerName));
broker.start();
broker.waitUntilStarted();
ActiveMQXAConnectionFactory cf = new ActiveMQXAConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri());
XAConnection connection = (XAConnection) cf.createConnection();
connection.start();
XASession session = connection.createXASession();
XAResource resource = session.getXAResource();
Destination dest = new ActiveMQQueue(getName());
// publish a message
Xid tid = createXid();
resource.start(tid, XAResource.TMNOFLAGS);
MessageProducer producer = session.createProducer(dest);
ActiveMQTextMessage message = new ActiveMQTextMessage();
message.setText(getName());
producer.send(message);
connection.close();
//comment out this check as it doesn't apply to artemis
//assertTransactionGoneFromBroker(tid);
broker.stop();
}
示例9: createBroker
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
public static BrokerService createBroker() throws Exception {
BrokerService b = null;
if (LOCAL_BROKER) {
b = BrokerFactory.createBroker("broker:(" + bindAddress + ")/EXAMPLE?persistent=false&useJmx=false&deleteAllMessagesOnStartup=true");
b.start();
}
return b;
}
示例10: createBroker
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
public static BrokerService createBroker(String name) throws Exception {
BrokerService b = BrokerFactory.createBroker("xbean:META-INF/org/apache/activemq/" + name + ".xml");
if (!name.equals(b.getBrokerName())) {
LOG.warn("Broker name mismatch (expecting '{}'). Check configuration.", name);
return null;
}
BROKERS.add(b);
b.start();
b.waitUntilStarted();
return b;
}
示例11: createNewBroker
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
public static BrokerService createNewBroker() throws Exception {
int index = BROKERS.size();
int port = PORT_START + index;
String bindAddress = "tcp://localhost:" + port;
String name = "BROKER-" + index;
BrokerService b = BrokerFactory.createBroker("broker:(" + bindAddress + ")/" + name + "?persistent=false&useJmx=true&deleteAllMessagesOnStartup=true");
BROKERS.add(b);
b.start();
return b;
}
示例12: before
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
public void before() throws Exception {
service = BrokerFactory.createBroker("xbean:activemq.xml");
service.start();
connectionFactory = new ActiveMQConnectionFactory(connectionUri);
connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = session.createQueue("MyQueue");
}
示例13: testBrokerDoubleCreate
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
public void testBrokerDoubleCreate() throws Exception {
BrokerService broker = BrokerFactory.createBroker(new URI(getBrokerUri("broker:(tcp://localhost:" + brokerPort + ")?useJmx=false")));
stopBroker(broker);
broker = BrokerFactory.createBroker(new URI(getBrokerUri("broker:(tcp://localhost:" + brokerPort + ")?useJmx=false")));
stopBroker(broker);
}
示例14: testNoDataSource
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
public void testNoDataSource() throws Exception {
final BrokerService broker = BrokerFactory.createBroker(new URI(getBrokerUri(
"broker:(tcp://localhost:" + brokerPort + ")?useJmx=false")));
assertNotNull("broker is null", broker);
final PersistenceAdapter persistenceAdapter = broker.getPersistenceAdapter();
assertNotNull("persistenceAdapter is null", persistenceAdapter);
assertTrue("persistenceAdapter should be an instance of MemoryPersistenceAdapter",
persistenceAdapter instanceof MemoryPersistenceAdapter);
stopBroker(broker);
}
示例15: testDirectDataSource
import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
public void testDirectDataSource() throws Exception {
final Properties properties = new Properties();
final JDBCDataSource dataSource = new JDBCDataSource();
dataSource.setDatabase("jdbc:hsqldb:mem:testdb" + System.currentTimeMillis());
dataSource.setUser("sa");
dataSource.setPassword("");
dataSource.getConnection().close();
properties.put("DataSource", dataSource);
properties.put("UseDatabaseLock", "false");
properties.put("StartupTimeout", "10000");
ActiveMQFactory.setThreadProperties(properties);
BrokerService broker = null;
try {
broker = BrokerFactory.createBroker(new URI(getBrokerUri(
"broker:(tcp://localhost:" + brokerPort + ")?useJmx=false")));
assertNotNull("broker is null", broker);
final PersistenceAdapter persistenceAdapter = broker.getPersistenceAdapter();
assertNotNull("persistenceAdapter is null", persistenceAdapter);
assertTrue("persistenceAdapter should be an instance of JDBCPersistenceAdapter",
persistenceAdapter instanceof JDBCPersistenceAdapter);
final JDBCPersistenceAdapter jdbcPersistenceAdapter = (JDBCPersistenceAdapter) persistenceAdapter;
assertSame(dataSource, jdbcPersistenceAdapter.getDataSource());
} finally {
stopBroker(broker);
ActiveMQFactory.setThreadProperties(null);
}
}