Search in sources :

Example 1 with LeaseDatabaseLocker

use of org.apache.activemq.store.jdbc.LeaseDatabaseLocker in project activemq-artemis by apache.

the class kahaDbJdbcLeaseQueueMasterSlaveTest method createMaster.

@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();
}
Also used : Statements(org.apache.activemq.store.jdbc.Statements) BrokerService(org.apache.activemq.broker.BrokerService) LeaseDatabaseLocker(org.apache.activemq.store.jdbc.LeaseDatabaseLocker) KahaDBPersistenceAdapter(org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter)

Example 2 with LeaseDatabaseLocker

use of org.apache.activemq.store.jdbc.LeaseDatabaseLocker in project activemq-artemis by apache.

the class DbRestartJDBCQueueMasterSlaveLeaseTest method configureJdbcPersistenceAdapter.

@Override
protected void configureJdbcPersistenceAdapter(JDBCPersistenceAdapter persistenceAdapter) throws IOException {
    super.configureJdbcPersistenceAdapter(persistenceAdapter);
    persistenceAdapter.setLocker(new LeaseDatabaseLocker());
    persistenceAdapter.getLocker().setLockAcquireSleepInterval(getLockAcquireSleepInterval());
    persistenceAdapter.setLockKeepAlivePeriod(getLockKeepAlivePeriod());
}
Also used : LeaseDatabaseLocker(org.apache.activemq.store.jdbc.LeaseDatabaseLocker)

Example 3 with LeaseDatabaseLocker

use of org.apache.activemq.store.jdbc.LeaseDatabaseLocker in project activemq-artemis by apache.

the class kahaDbJdbcLeaseQueueMasterSlaveTest method createSlave.

@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();
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) Statements(org.apache.activemq.store.jdbc.Statements) BrokerService(org.apache.activemq.broker.BrokerService) URI(java.net.URI) LeaseDatabaseLocker(org.apache.activemq.store.jdbc.LeaseDatabaseLocker) IOException(java.io.IOException) KahaDBPersistenceAdapter(org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter)

Aggregations

LeaseDatabaseLocker (org.apache.activemq.store.jdbc.LeaseDatabaseLocker)3 BrokerService (org.apache.activemq.broker.BrokerService)2 Statements (org.apache.activemq.store.jdbc.Statements)2 KahaDBPersistenceAdapter (org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter)2 IOException (java.io.IOException)1 URI (java.net.URI)1 TransportConnector (org.apache.activemq.broker.TransportConnector)1