use of org.apache.activemq.store.jdbc.JDBCPersistenceAdapter in project activemq-artemis by apache.
the class JdbcXARecoveryBrokerTest method configureBroker.
@Override
protected void configureBroker(BrokerService broker) throws Exception {
super.configureBroker(broker);
JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
jdbc.setDataSource(dataSource);
broker.setPersistenceAdapter(jdbc);
}
use of org.apache.activemq.store.jdbc.JDBCPersistenceAdapter in project activemq-artemis by apache.
the class JDBCPersistenceAdapterXBeanConfigTest method testConfiguredCorrectly.
public void testConfiguredCorrectly() throws Exception {
PersistenceAdapter persistenceAdapter = brokerService.getPersistenceAdapter();
assertNotNull(persistenceAdapter);
assertTrue(persistenceAdapter instanceof JDBCPersistenceAdapter);
JDBCPersistenceAdapter jpa = (JDBCPersistenceAdapter) persistenceAdapter;
assertEquals("BROKER1.", jpa.getStatements().getTablePrefix());
}
use of org.apache.activemq.store.jdbc.JDBCPersistenceAdapter in project activemq-artemis by apache.
the class ConfigTest method testJdbcLockConfigDefault.
public void testJdbcLockConfigDefault() throws Exception {
JDBCPersistenceAdapter adapter = new JDBCPersistenceAdapter();
Mockery context = new Mockery();
final DataSource dataSource = context.mock(DataSource.class);
final Connection connection = context.mock(Connection.class);
final DatabaseMetaData metadata = context.mock(DatabaseMetaData.class);
final ResultSet result = context.mock(ResultSet.class);
adapter.setDataSource(dataSource);
adapter.setCreateTablesOnStartup(false);
context.checking(new Expectations() {
{
allowing(dataSource).getConnection();
will(returnValue(connection));
allowing(connection).getMetaData();
will(returnValue(metadata));
allowing(connection);
allowing(metadata).getDriverName();
will(returnValue("Some_Unknown_driver"));
allowing(result).next();
will(returnValue(true));
}
});
adapter.start();
assertEquals("has the default locker", adapter.getLocker().getClass(), DefaultDatabaseLocker.class);
adapter.stop();
}
use of org.apache.activemq.store.jdbc.JDBCPersistenceAdapter in project activemq-artemis by apache.
the class DbRestartJDBCQueueTest method setUp.
@Override
protected void setUp() throws Exception {
setAutoFail(true);
topic = false;
verbose = true;
// startup db
sharedDs = (EmbeddedDataSource) DataSourceServiceSupport.createDataSource(IOHelper.getDefaultDataDirectory());
broker = new BrokerService();
DefaultIOExceptionHandler handler = new DefaultIOExceptionHandler();
handler.setIgnoreSQLExceptions(false);
handler.setStopStartConnectors(true);
broker.setIoExceptionHandler(handler);
broker.addConnector("tcp://localhost:0");
broker.setUseJmx(false);
broker.setPersistent(true);
broker.setDeleteAllMessagesOnStartup(true);
JDBCPersistenceAdapter persistenceAdapter = new JDBCPersistenceAdapter();
persistenceAdapter.setDataSource(sharedDs);
persistenceAdapter.setUseLock(false);
persistenceAdapter.setLockKeepAlivePeriod(500);
persistenceAdapter.getLocker().setLockAcquireSleepInterval(500);
broker.setPersistenceAdapter(persistenceAdapter);
broker.start();
super.setUp();
}
use of org.apache.activemq.store.jdbc.JDBCPersistenceAdapter in project activemq-artemis by apache.
the class RecoverExpiredMessagesTest method initCombosForTestRecovery.
public void initCombosForTestRecovery() throws Exception {
addCombinationValues("queuePendingPolicy", new PendingQueueMessageStoragePolicy[] { new FilePendingQueueMessageStoragePolicy(), new VMPendingQueueMessageStoragePolicy() });
PersistenceAdapter[] persistenceAdapters = new PersistenceAdapter[] { new KahaDBPersistenceAdapter(), new JDBCPersistenceAdapter(DataSourceServiceSupport.createDataSource(IOHelper.getDefaultDataDirectory()), new OpenWireFormat()) };
for (PersistenceAdapter adapter : persistenceAdapters) {
adapter.setDirectory(new File(IOHelper.getDefaultDataDirectory()));
}
addCombinationValues("persistenceAdapter", persistenceAdapters);
}
Aggregations