use of org.apache.activemq.store.jdbc.Statements 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();
}
use of org.apache.activemq.store.jdbc.Statements 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();
}
Aggregations