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


Java BrokerService.getPersistenceAdapter方法代碼示例

本文整理匯總了Java中org.apache.activemq.broker.BrokerService.getPersistenceAdapter方法的典型用法代碼示例。如果您正苦於以下問題:Java BrokerService.getPersistenceAdapter方法的具體用法?Java BrokerService.getPersistenceAdapter怎麽用?Java BrokerService.getPersistenceAdapter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.activemq.broker.BrokerService的用法示例。


在下文中一共展示了BrokerService.getPersistenceAdapter方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

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

示例2: 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

示例3: execute

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
public void execute() throws Exception {
    if (config == null) {
        throw new Exception("required --config option missing");
    }
    if (file == null) {
        throw new Exception("required --file option missing");
    }
    System.out.println("Loading: " + config);
    BrokerFactory.setStartDefault(false); // to avoid the broker auto-starting..
    BrokerService broker = BrokerFactory.createBroker(config);
    BrokerFactory.resetStartDefault();
    PersistenceAdapter store = broker.getPersistenceAdapter();
    System.out.println("Starting: " + store);
    store.start();
    try {
        BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(file));
        try {
            export(store, fos);
        } finally {
            fos.close();
        }
    } finally {
        store.stop();
    }
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:26,代碼來源:StoreExporter.java

示例4: createSlave

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Override
protected void createSlave() throws Exception {
   // use a separate thread as the slave will block waiting for
   // the exclusive db lock
   Thread t = new Thread() {
      @Override
      public void run() {
         try {
            BrokerService broker = new BrokerService();
            broker.setBrokerName("slave");
            TransportConnector connector = new TransportConnector();
            connector.setUri(new URI(SLAVE_URL));
            broker.addConnector(connector);
            broker.setUseJmx(false);
            broker.setPersistent(true);
            KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter();
            LeaseDatabaseLocker leaseDatabaseLocker = new LeaseDatabaseLocker();
            leaseDatabaseLocker.setDataSource(getExistingDataSource());
            leaseDatabaseLocker.setStatements(new Statements());
            kahaDBPersistenceAdapter.setLocker(leaseDatabaseLocker);
            configureLocker(kahaDBPersistenceAdapter);
            configureBroker(broker);
            broker.start();
            slave.set(broker);
            slaveStarted.countDown();
         } catch (IllegalStateException expectedOnShutdown) {
         } catch (Exception e) {
            fail("failed to start slave broker, reason:" + e);
         }
      }
   };
   t.start();
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:34,代碼來源:kahaDbJdbcLeaseQueueMasterSlaveTest.java

示例5: testJournaledJDBCConfig

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Test
public void testJournaledJDBCConfig() throws Exception {

   File journalFile = new File(JOURNAL_ROOT + "testJournaledJDBCConfig/journal");
   recursiveDelete(journalFile);

   File derbyFile = new File(DERBY_ROOT + "testJournaledJDBCConfig/derbydb"); // Default
   recursiveDelete(derbyFile);

   BrokerService broker;
   broker = createBroker(new FileSystemResource(CONF_ROOT + "journaledjdbc-example.xml"));
   try {
      assertEquals("Broker Config Error (brokerName)", "brokerJournaledJDBCConfigTest", broker.getBrokerName());

      PersistenceAdapter adapter = broker.getPersistenceAdapter();

      assertTrue("Should have created a journal persistence adapter", adapter instanceof JournalPersistenceAdapter);
      assertTrue("Should have created a derby directory at " + derbyFile.getAbsolutePath(), derbyFile.exists());
      assertTrue("Should have created a journal directory at " + journalFile.getAbsolutePath(), journalFile.exists());

      // Check persistence factory configurations
      broker.getPersistenceAdapter();

      assertTrue(broker.getSystemUsage().getStoreUsage().getStore() instanceof JournalPersistenceAdapter);

      LOG.info("Success");
   } finally {
      if (broker != null) {
         broker.stop();
      }
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:33,代碼來源:ConfigTest.java

示例6: testMemoryConfig

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Test
public void testMemoryConfig() throws Exception {
   File journalFile = new File(JOURNAL_ROOT + "testMemoryConfig");
   recursiveDelete(journalFile);

   File derbyFile = new File(DERBY_ROOT + "testMemoryConfig");
   recursiveDelete(derbyFile);

   BrokerService broker;
   broker = createBroker(new FileSystemResource(CONF_ROOT + "memory-example.xml"));

   try {
      assertEquals("Broker Config Error (brokerName)", "brokerMemoryConfigTest", broker.getBrokerName());

      PersistenceAdapter adapter = broker.getPersistenceAdapter();

      assertTrue("Should have created a memory persistence adapter", adapter instanceof MemoryPersistenceAdapter);
      assertTrue("Should have not created a derby directory at " + derbyFile.getAbsolutePath(), !derbyFile.exists());
      assertTrue("Should have not created a journal directory at " + journalFile.getAbsolutePath(), !journalFile.exists());

      LOG.info("Success");
   } finally {
      if (broker != null) {
         broker.stop();
      }
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:28,代碼來源:ConfigTest.java

示例7: testJdbcConfig

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Test
public void testJdbcConfig() throws Exception {
   File journalFile = new File(JOURNAL_ROOT + "testJDBCConfig/journal");
   recursiveDelete(journalFile);

   File derbyFile = new File(DERBY_ROOT + "testJDBCConfig/derbydb"); // Default
   recursiveDelete(derbyFile);

   BrokerService broker;
   broker = createBroker(new FileSystemResource(CONF_ROOT + "jdbc-example.xml"));
   try {
      assertEquals("Broker Config Error (brokerName)", "brokerJdbcConfigTest", broker.getBrokerName());

      PersistenceAdapter adapter = broker.getPersistenceAdapter();

      assertTrue("Should have created a jdbc persistence adapter", adapter instanceof JDBCPersistenceAdapter);
      assertEquals("JDBC Adapter Config Error (cleanupPeriod)", 60000, ((JDBCPersistenceAdapter) adapter).getCleanupPeriod());
      assertTrue("Should have created an EmbeddedDataSource", ((JDBCPersistenceAdapter) adapter).getDataSource() instanceof EmbeddedDataSource);
      assertTrue("Should have created a DefaultWireFormat", ((JDBCPersistenceAdapter) adapter).getWireFormat() instanceof ObjectStreamWireFormat);

      LOG.info("Success");
   } finally {
      if (broker != null) {
         broker.stop();
      }
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:28,代碼來源:JDBCConfigTest.java

示例8: 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


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