Search in sources :

Example 16 with JDBCPersistenceAdapter

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

the class JDBCPersistenceXBeanConfigTest 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 17 with JDBCPersistenceAdapter

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

the class JdbcDurableSubDupTest method startBroker.

@Before
public void startBroker() throws Exception {
    exceptions.clear();
    for (int i = 0; i < MAX_MESSAGES; i++) {
        dupChecker[i] = 0;
    }
    broker = new BrokerService();
    broker.setAdvisorySupport(false);
    broker.setPersistenceAdapter(new JDBCPersistenceAdapter());
    PolicyEntry policyEntry = new PolicyEntry();
    policyEntry.setMaxAuditDepth(3000);
    policyEntry.setMaxPageSize(150);
    policyEntry.setPrioritizedMessages(true);
    PolicyMap policyMap = new PolicyMap();
    policyMap.setDefaultEntry(policyEntry);
    broker.setDestinationPolicy(policyMap);
    broker.addConnector("tcp://localhost:0");
    broker.setDeleteAllMessagesOnStartup(true);
    broker.start();
    broker.waitUntilStarted();
    url = broker.getTransportConnectors().get(0).getConnectUri().toString() + "?" + urlOptions;
}
Also used : JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) BrokerService(org.apache.activemq.broker.BrokerService) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry) Before(org.junit.Before)

Example 18 with JDBCPersistenceAdapter

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

the class ConfigTest method testJdbcLockConfigOverride.

@Test
public void testJdbcLockConfigOverride() 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("Microsoft_SQL_Server_2005_jdbc_driver"));
            allowing(result).next();
            will(returnValue(true));
        }
    });
    adapter.start();
    assertTrue("has the locker override", adapter.getLocker() instanceof TransactDatabaseLocker);
    adapter.stop();
}
Also used : Expectations(org.jmock.Expectations) JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) TransactDatabaseLocker(org.apache.activemq.store.jdbc.adapter.TransactDatabaseLocker) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) DatabaseMetaData(java.sql.DatabaseMetaData) Mockery(org.jmock.Mockery) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 19 with JDBCPersistenceAdapter

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

the class JDBCConfigTest method testJdbcConfig.

/*
    * This tests creating a jdbc persistence adapter using xbeans-spring
    */
@Test
public void testJdbcConfig() throws Exception {
    File journalFile = new File(JOURNAL_ROOT + "testJDBCConfig/journal");
    recursiveDelete(journalFile);
    // Default
    File derbyFile = new File(DERBY_ROOT + "testJDBCConfig/derbydb");
    recursiveDelete(derbyFile);
    BrokerService broker;
    broker = createBroker(new FileSystemResource(CONF_ROOT + "jdbc-example.xml"));
    try {
        assertEquals("Broker Config Error (brokerName)", "brokerJdbcConfigTest", broker.getBrokerName());
        PersistenceAdapter adapter = broker.getPersistenceAdapter();
        assertTrue("Should have created a jdbc persistence adapter", adapter instanceof JDBCPersistenceAdapter);
        assertEquals("JDBC Adapter Config Error (cleanupPeriod)", 60000, ((JDBCPersistenceAdapter) adapter).getCleanupPeriod());
        assertTrue("Should have created an EmbeddedDataSource", ((JDBCPersistenceAdapter) adapter).getDataSource() instanceof EmbeddedDataSource);
        assertTrue("Should have created a DefaultWireFormat", ((JDBCPersistenceAdapter) adapter).getWireFormat() instanceof ObjectStreamWireFormat);
        LOG.info("Success");
    } finally {
        if (broker != null) {
            broker.stop();
        }
    }
}
Also used : JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) FileSystemResource(org.springframework.core.io.FileSystemResource) EmbeddedDataSource(org.apache.derby.jdbc.EmbeddedDataSource) File(java.io.File) BrokerService(org.apache.activemq.broker.BrokerService) JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) PersistenceAdapter(org.apache.activemq.store.PersistenceAdapter) ObjectStreamWireFormat(org.apache.activemq.wireformat.ObjectStreamWireFormat) Test(org.junit.Test)

Example 20 with JDBCPersistenceAdapter

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

the class StoreQueueCursorJDBCNoDuplicateTest method createBroker.

@Override
protected BrokerService createBroker() throws Exception {
    BrokerService broker = super.createBroker();
    PersistenceAdapter persistenceAdapter = new JDBCPersistenceAdapter();
    broker.setPersistenceAdapter(persistenceAdapter);
    return broker;
}
Also used : JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) BrokerService(org.apache.activemq.broker.BrokerService) JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) PersistenceAdapter(org.apache.activemq.store.PersistenceAdapter)

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