Java Code Examples for org.apache.activemq.store.jdbc.JDBCPersistenceAdapter#setCreateTablesOnStartup()
The following examples show how to use
org.apache.activemq.store.jdbc.JDBCPersistenceAdapter#setCreateTablesOnStartup() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivemqConfiguration.java From onetwo with Apache License 2.0 | 5 votes |
@Bean public PersistenceAdapter jdbcPersistenceAdapter(DataSource dataSource){ JdbcStoreProps jdbcProps = activemqProperties.getJdbcStore(); JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter(dataSource, new OpenWireFormat()); jdbc.setCreateTablesOnStartup(jdbcProps.isCreateTablesOnStartup()); return jdbc; }
Example 2
Source File: JDBCQueueMasterSlaveTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@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); // no need for broker.setMasterConnectorURI(masterConnectorURI) // as the db lock provides the slave/master initialisation broker.setUseJmx(false); broker.setPersistent(true); JDBCPersistenceAdapter persistenceAdapter = new JDBCPersistenceAdapter(); persistenceAdapter.setDataSource(getExistingDataSource()); persistenceAdapter.setCreateTablesOnStartup(false); broker.setPersistenceAdapter(persistenceAdapter); configureJdbcPersistenceAdapter(persistenceAdapter); 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(); }
Example 3
Source File: ConfigTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@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(); }
Example 4
Source File: ConfigTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
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(); }