Search in sources :

Example 1 with JDBCPersistenceAdapter

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);
}
Also used : JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter)

Example 2 with JDBCPersistenceAdapter

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());
}
Also used : JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) PersistenceAdapter(org.apache.activemq.store.PersistenceAdapter)

Example 3 with JDBCPersistenceAdapter

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();
}
Also used : Expectations(org.jmock.Expectations) JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) DatabaseMetaData(java.sql.DatabaseMetaData) Mockery(org.jmock.Mockery) DataSource(javax.sql.DataSource)

Example 4 with JDBCPersistenceAdapter

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();
}
Also used : DefaultIOExceptionHandler(org.apache.activemq.util.DefaultIOExceptionHandler) JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) BrokerService(org.apache.activemq.broker.BrokerService)

Example 5 with JDBCPersistenceAdapter

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);
}
Also used : OpenWireFormat(org.apache.activemq.openwire.OpenWireFormat) JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) VMPendingQueueMessageStoragePolicy(org.apache.activemq.broker.region.policy.VMPendingQueueMessageStoragePolicy) FilePendingQueueMessageStoragePolicy(org.apache.activemq.broker.region.policy.FilePendingQueueMessageStoragePolicy) File(java.io.File) JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) KahaDBPersistenceAdapter(org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter) PersistenceAdapter(org.apache.activemq.store.PersistenceAdapter) KahaDBPersistenceAdapter(org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter)

Aggregations

JDBCPersistenceAdapter (org.apache.activemq.store.jdbc.JDBCPersistenceAdapter)20 BrokerService (org.apache.activemq.broker.BrokerService)10 PersistenceAdapter (org.apache.activemq.store.PersistenceAdapter)10 MemoryPersistenceAdapter (org.apache.activemq.store.memory.MemoryPersistenceAdapter)5 URI (java.net.URI)4 KahaDBPersistenceAdapter (org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter)4 File (java.io.File)3 Properties (java.util.Properties)3 DataSource (javax.sql.DataSource)3 Connection (java.sql.Connection)2 DatabaseMetaData (java.sql.DatabaseMetaData)2 ResultSet (java.sql.ResultSet)2 PolicyEntry (org.apache.activemq.broker.region.policy.PolicyEntry)2 PolicyMap (org.apache.activemq.broker.region.policy.PolicyMap)2 LevelDBPersistenceAdapter (org.apache.activemq.store.leveldb.LevelDBPersistenceAdapter)2 EmbeddedDataSource (org.apache.derby.jdbc.EmbeddedDataSource)2 JDBCDataSource (org.hsqldb.jdbc.JDBCDataSource)2 Expectations (org.jmock.Expectations)2 Mockery (org.jmock.Mockery)2 Test (org.junit.Test)2