Java Code Examples for org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter#setLocker()

The following examples show how to use org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter#setLocker() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: kahaDbJdbcLeaseQueueMasterSlaveTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 2
Source File: kahaDbJdbcLeaseQueueMasterSlaveTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@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();
}