本文整理汇总了Java中org.apache.activemq.broker.BrokerService.stop方法的典型用法代码示例。如果您正苦于以下问题:Java BrokerService.stop方法的具体用法?Java BrokerService.stop怎么用?Java BrokerService.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.broker.BrokerService
的用法示例。
在下文中一共展示了BrokerService.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
public void run() {
try {
BrokerService broker = new BrokerService();
synchronized (this) {
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.setTmpDataDirectory(new File("./target"));
broker.addConnector(brokerUrl);
broker.start();
Thread.sleep(200);
notifyAll();
}
synchronized (this) {
while (!shutdownBroker) {
wait(1000);
}
}
broker.stop();
broker = null;
} catch (Exception e) {
exception = e;
e.printStackTrace();
}
}
示例2: run
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
public void run() {
try {
BrokerService broker = new BrokerService();
synchronized (this) {
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.setTmpDataDirectory(new File("./target"));
broker.addConnector(brokerUrl);
broker.start();
Thread.sleep(200);
notifyAll();
}
synchronized (this) {
while (!shutdownBroker) {
wait(1000);
}
}
broker.stop();
} catch (Exception e) {
exception = e;
e.printStackTrace();
}
}
示例3: performJmsTransportTest
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
private void performJmsTransportTest(final String springBeanXml) throws IOException, URISyntaxException, Exception
{
final BrokerService broker = setupJmsBroker();
//
// now we get the jax-rs endpoint from the xml config
try (ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { springBeanXml }))
{
final JAXRSServerFactoryBean sfb = (JAXRSServerFactoryBean)ctx.getBean("jaxrs:server:jms");
final Server server = sfb.getServer();
assertThat(server, notNullValue()); // it's important that we can obtain the server bean
assertThat(server.isStarted(), is(true)); // for all we care, we could also start the server, but we need to know if we have to or not
runJmsClient();
server.destroy();
assertThat(server.isStarted(), is(false));
}
finally
{
broker.stop();
}
}
示例4: testServerWithJmsTransport
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
@Test
public void testServerWithJmsTransport() throws Exception
{
final BrokerService jmsBroker = setupJmsBroker();
try
{
final List<Class<?>> providers = Arrays.asList(TestService.class, TestService2.class);
final Server server = createServer(providers);
assertThat(server, notNullValue()); // it's important that we can obtain the server bean
assertThat(server.isStarted(), is(true)); // for all we care, we could also start the server, but we need to know if we have to or not
runJmsClient();
server.destroy();
assertThat(server.isStarted(), is(false));
}
finally
{
jmsBroker.stop();
}
}
示例5: testStartupShutdown
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
public void testStartupShutdown() throws Exception {
// This systemproperty is used if we dont want to
// have persistence messages as a default
System.setProperty("activemq.persistenceAdapter", "org.apache.activemq.store.vm.VMPersistenceAdapter");
// configuration of container and all protocols
BrokerService broker = createBroker();
// start a client
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:9100");
factory.createConnection();
// stop activemq broker
broker.stop();
// start activemq broker again
broker = createBroker();
// start a client again
factory = new ActiveMQConnectionFactory("tcp://localhost:9100");
factory.createConnection();
// stop activemq broker
broker.stop();
}
示例6: testRollbackXaErrorCode
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
public void testRollbackXaErrorCode() throws Exception {
String brokerName = "rollbackErrorCode";
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();
Xid tid = createXid();
try {
resource.rollback(tid);
fail("Expected xa exception on no tx");
} catch (XAException expected) {
LOG.info("got expected xa", expected);
assertEquals("no tx", XAException.XAER_NOTA, expected.errorCode);
}
connection.close();
broker.stop();
}
示例7: testJournalConfig
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
@Test
public void testJournalConfig() throws Exception {
File journalFile = new File(JOURNAL_ROOT + "testJournalConfig/journal");
recursiveDelete(journalFile);
BrokerService broker;
broker = createBroker(new FileSystemResource(CONF_ROOT + "journal-example.xml"));
try {
assertEquals("Broker Config Error (brokerName)", "brokerJournalConfigTest", broker.getBrokerName());
PersistenceAdapter adapter = broker.getPersistenceAdapter();
assertTrue("Should have created a journal persistence adapter", adapter instanceof JournalPersistenceAdapter);
assertTrue("Should have created a journal directory at " + journalFile.getAbsolutePath(), journalFile.exists());
LOG.info("Success");
} finally {
if (broker != null) {
broker.stop();
}
}
}
示例8: stopActiveMq
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
private static void stopActiveMq(BrokerService brokerService) {
log.info("## Shutting down ActiveMQ.");
// :: Close the AMQ Broker
try {
brokerService.stop();
}
catch (Exception e) {
throw new IllegalStateException("Couldn't stop AMQ BrokerService!", e);
}
log.info("## ActiveMQ shut down.");
}
示例9: tearDown
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
@Override
public void tearDown() throws Exception {
for (BrokerService broker : brokers) {
broker.stop();
}
brokers.clear();
}
示例10: testCreateTcpConnectionUsingKnownLocalPort
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
public void testCreateTcpConnectionUsingKnownLocalPort() throws Exception {
broker = new BrokerService();
broker.setPersistent(false);
broker.addConnector("tcp://localhost:61610?wireFormat.tcpNoDelayEnabled=true");
broker.start();
// This should create the connection.
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61610/localhost:51610");
connection = (ActiveMQConnection) cf.createConnection();
assertNotNull(connection);
connection.close();
broker.stop();
}
示例11: stopBrokerWithStoreFailure
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
public void stopBrokerWithStoreFailure(BrokerService broker, PersistenceAdapterChoice choice) throws Exception {
switch (choice) {
case KahaDB:
KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter();
// have the broker stop with an IOException on next checkpoint so it has a pending local transaction to recover
kahaDBPersistenceAdapter.getStore().getJournal().close();
break;
default:
// just stop normally by default
broker.stop();
}
broker.waitUntilStopped();
}
示例12: testMbeanPresenceOnBrokerRestart
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
@Test
public void testMbeanPresenceOnBrokerRestart() throws Exception {
BrokerService networkedBroker = createNetworkedBroker();
try {
networkedBroker.start();
assertEquals(1, countMbeans(networkedBroker, "connector=networkConnectors", 30000));
assertEquals(0, countMbeans(networkedBroker, "connectionName"));
BrokerService broker = null;
for (int i = 0; i < numRestarts; i++) {
broker = createBroker();
try {
broker.start();
assertEquals(1, countMbeans(networkedBroker, "networkBridge", 5000));
assertEquals("restart number: " + i, 2, countMbeans(broker, "connectionName", 10000));
} finally {
broker.stop();
broker.waitUntilStopped();
}
assertEquals(0, countMbeans(broker, "stopped"));
}
assertEquals(1, countMbeans(networkedBroker, "connector=networkConnectors"));
assertEquals(0, countMbeans(networkedBroker, "connectionName"));
assertEquals(0, countMbeans(broker, "connectionName"));
} finally {
networkedBroker.stop();
networkedBroker.waitUntilStopped();
}
}
示例13: testLoopbackOnDifferentUrlScheme
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
@Test
public void testLoopbackOnDifferentUrlScheme() throws Exception {
final BrokerService brokerServce = new BrokerService();
brokerServce.setPersistent(false);
TransportConnector transportConnector = brokerServce.addConnector("nio://0.0.0.0:0");
// connection filter is bypassed when scheme is different
final NetworkConnector networkConnector = brokerServce.addNetworkConnector("static:(tcp://" + transportConnector.getConnectUri().getHost() + ":" + transportConnector.getConnectUri().getPort() + ")");
brokerServce.start();
brokerServce.waitUntilStarted();
try {
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 1 == networkConnector.bridges.size();
}
});
final DemandForwardingBridgeSupport loopbackBridge = (DemandForwardingBridgeSupport) networkConnector.bridges.values().iterator().next();
assertTrue("nc started", networkConnector.isStarted());
assertTrue("It should get disposed", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return loopbackBridge.getRemoteBroker().isDisposed();
}
}));
assertEquals("No peer brokers", 0, brokerServce.getBroker().getPeerBrokerInfos().length);
} finally {
brokerServce.stop();
}
}
示例14: tearDown
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
@Override
protected void tearDown() throws Exception {
super.tearDown();
master.stop();
master.waitUntilStopped();
slaveStarted.await(60, TimeUnit.SECONDS);
BrokerService brokerService = slave.get();
if (brokerService != null) {
brokerService.stop();
}
master.stop();
}
示例15: verifyCredentials
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
private boolean verifyCredentials(String name) throws Exception {
boolean result = false;
BrokerService broker = getBroker(name);
assertNotNull(name, broker);
broker.start();
broker.waitUntilStarted();
try {
result = verifySslCredentials(broker);
} finally {
broker.stop();
}
return result;
}