當前位置: 首頁>>代碼示例>>Java>>正文


Java BrokerService.stop方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:24,代碼來源:JmsBroker.java

示例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();
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:23,代碼來源:JmsBroker.java

示例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();
	}
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:25,代碼來源:JaxRsSpringEndpointTests.java

示例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();
	}
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:24,代碼來源:JaxRsProgramaticTests.java

示例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();

}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:27,代碼來源:StartAndStopBrokerTest.java

示例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();
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:23,代碼來源:ActiveMQXAConnectionFactoryTest.java

示例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();
      }
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:23,代碼來源:ConfigTest.java

示例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.");
}
 
開發者ID:stolsvik,項目名稱:mats,代碼行數:12,代碼來源:ActiveMqStarter.java

示例9: tearDown

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Override
public void tearDown() throws Exception {
   for (BrokerService broker : brokers) {
      broker.stop();
   }
   brokers.clear();
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:8,代碼來源:RequestReplyNoAdvisoryNetworkTest.java

示例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();
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:16,代碼來源:ActiveMQConnectionFactoryTest.java

示例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();
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:15,代碼來源:TestSupport.java

示例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();
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:32,代碼來源:DuplexNetworkMBeanTest.java

示例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();
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:37,代碼來源:NetworkLoopBackTest.java

示例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();
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:13,代碼來源:QueueMasterSlaveTestSupport.java

示例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;
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:14,代碼來源:SslContextNBrokerServiceTest.java


注:本文中的org.apache.activemq.broker.BrokerService.stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。