org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter Java Examples
The following examples show how to use
org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter.
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: mKahaDbQueueMasterSlaveTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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); MultiKahaDBPersistenceAdapter mKahaDB = new MultiKahaDBPersistenceAdapter(); List<FilteredKahaDBPersistenceAdapter> adapters = new LinkedList<>(); FilteredKahaDBPersistenceAdapter defaultEntry = new FilteredKahaDBPersistenceAdapter(); defaultEntry.setPersistenceAdapter(new KahaDBPersistenceAdapter()); defaultEntry.setPerDestination(true); adapters.add(defaultEntry); mKahaDB.setFilteredPersistenceAdapters(adapters); master.setPersistenceAdapter(mKahaDB); master.start(); }
Example #2
Source File: DurableSubscriptionActivationTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
private void createBroker(boolean delete) throws Exception { broker = BrokerFactory.createBroker("broker:(vm://localhost)"); broker.setKeepDurableSubsActive(true); broker.setPersistent(true); broker.setDeleteAllMessagesOnStartup(delete); KahaDBPersistenceAdapter kahadb = new KahaDBPersistenceAdapter(); kahadb.setDirectory(new File("activemq-data/" + getName() + "-kahadb")); kahadb.setJournalMaxFileLength(500 * 1024); broker.setPersistenceAdapter(kahadb); broker.setBrokerName(getName()); // only if we pre-create the destinations broker.setDestinations(new ActiveMQDestination[]{topic}); broker.start(); broker.waitUntilStarted(); connection = createConnection(); }
Example #3
Source File: DurableSubProcessTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
private void startBroker(boolean deleteAllMessages) throws Exception { if (broker != null) return; broker = BrokerFactory.createBroker("broker:(vm://localhost)"); broker.setBrokerName(getName()); broker.setDeleteAllMessagesOnStartup(deleteAllMessages); if (PERSISTENT_BROKER) { broker.setPersistent(true); KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter(); persistenceAdapter.setDirectory(new File("activemq-data/" + getName())); broker.setPersistenceAdapter(persistenceAdapter); } else broker.setPersistent(false); broker.addConnector("tcp://localhost:61656"); broker.getSystemUsage().getMemoryUsage().setLimit(256 * 1024 * 1024); broker.getSystemUsage().getTempUsage().setLimit(256 * 1024 * 1024); broker.getSystemUsage().getStoreUsage().setLimit(256 * 1024 * 1024); broker.start(); }
Example #4
Source File: kahaDbJdbcLeaseQueueMasterSlaveTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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(); }
Example #5
Source File: DurableSubscriptionUnsubscribeTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
private void startBroker(boolean deleteMessages) throws Exception { broker = BrokerFactory.createBroker("broker:(vm://" + getName() + ")"); broker.setUseJmx(true); broker.getManagementContext().setCreateConnector(false); broker.setBrokerName(getName()); broker.setPersistent(true); KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter(); persistenceAdapter.setDirectory(new File("activemq-data/" + getName())); broker.setPersistenceAdapter(persistenceAdapter); if (deleteMessages) { broker.setDeleteAllMessagesOnStartup(true); } broker.setKeepDurableSubsActive(true); broker.start(); broker.waitUntilStarted(); connection = createConnection(); }
Example #6
Source File: QueuePurgeTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override protected void setUp() throws Exception { setMaxTestTime(10 * 60 * 1000); // 10 mins setAutoFail(true); super.setUp(); broker = new BrokerService(); File testDataDir = new File("target/activemq-data/QueuePurgeTest"); broker.setDataDirectoryFile(testDataDir); broker.setUseJmx(true); broker.setDeleteAllMessagesOnStartup(true); broker.getSystemUsage().getMemoryUsage().setLimit(1024L * 1024 * 64); KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter(); persistenceAdapter.setDirectory(new File(testDataDir, "kahadb")); broker.setPersistenceAdapter(persistenceAdapter); broker.addConnector("tcp://localhost:0"); broker.start(); factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri().toString()); connection = factory.createConnection(); connection.start(); }
Example #7
Source File: mKahaDBXARecoveryBrokerTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override protected void configureBroker(BrokerService broker) throws Exception { super.configureBroker(broker); MultiKahaDBPersistenceAdapter mKahaDB = new MultiKahaDBPersistenceAdapter(); List<FilteredKahaDBPersistenceAdapter> adapters = new LinkedList<>(); FilteredKahaDBPersistenceAdapter defaultEntry = new FilteredKahaDBPersistenceAdapter(); defaultEntry.setPersistenceAdapter(new KahaDBPersistenceAdapter()); adapters.add(defaultEntry); FilteredKahaDBPersistenceAdapter special = new FilteredKahaDBPersistenceAdapter(); special.setDestination(new ActiveMQQueue("special")); special.setPersistenceAdapter(new KahaDBPersistenceAdapter()); adapters.add(special); mKahaDB.setFilteredPersistenceAdapters(adapters); broker.setPersistenceAdapter(mKahaDB); }
Example #8
Source File: NumberOfDestinationsTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
protected void configureBroker(BrokerService answer) throws Exception { File dataFileDir = new File("target/test-amq-data/perfTest/kahadb"); KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter(); kaha.setDirectory(dataFileDir); //answer.setUseJmx(false); // The setEnableJournalDiskSyncs(false) setting is a little dangerous right now, as I have not verified // what happens if the index is updated but a journal update is lost. // Index is going to be in consistent, but can it be repaired? //kaha.setEnableJournalDiskSyncs(false); // Using a bigger journal file size makes he take fewer spikes as it is not switching files as often. //kaha.setJournalMaxFileLength(1024*100); // small batch means more frequent and smaller writes //kaha.setIndexWriteBatchSize(100); // do the index write in a separate thread //kaha.setEnableIndexWriteAsync(true); answer.setPersistenceAdapter(kaha); answer.setAdvisorySupport(false); answer.setEnableStatistics(false); answer.addConnector(bindAddress); answer.setDeleteAllMessagesOnStartup(true); }
Example #9
Source File: DurableSubSelectorDelayWithRestartTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void startBroker(boolean deleteAllMessages) throws Exception { if (broker != null) return; broker = BrokerFactory.createBroker("broker:(vm://" + getName() + ")"); broker.setBrokerName(getName()); broker.setAdvisorySupport(false); broker.setDeleteAllMessagesOnStartup(deleteAllMessages); File kahadbData = new File("activemq-data/" + getName() + "-kahadb"); if (deleteAllMessages) delete(kahadbData); broker.setPersistent(true); KahaDBPersistenceAdapter kahadb = new KahaDBPersistenceAdapter(); kahadb.setDirectory(kahadbData); kahadb.setJournalMaxFileLength(10 * 1024); kahadb.setCleanupInterval(5000); broker.setPersistenceAdapter(kahadb); broker.addConnector("tcp://localhost:61656"); broker.getSystemUsage().getMemoryUsage().setLimit(256 * 1024 * 1024); broker.getSystemUsage().getTempUsage().setLimit(256 * 1024 * 1024); broker.getSystemUsage().getStoreUsage().setLimit(256 * 1024 * 1024); LOG.info(toString() + "Starting Broker..."); broker.start(); broker.waitUntilStarted(); LOG.info(toString() + " Broker started!!"); }
Example #10
Source File: DurableSubDelayedUnsubscribeTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void startBroker(boolean deleteAllMessages) throws Exception { if (broker != null) return; broker = BrokerFactory.createBroker("broker:(vm://" + getName() + ")"); broker.setBrokerName(getName()); broker.setAdvisorySupport(false); broker.setDeleteAllMessagesOnStartup(deleteAllMessages); File kahadbData = new File("activemq-data/" + getName() + "-kahadb"); if (deleteAllMessages) delete(kahadbData); broker.setPersistent(true); KahaDBPersistenceAdapter kahadb = new KahaDBPersistenceAdapter(); kahadb.setDirectory(kahadbData); kahadb.setJournalMaxFileLength(512 * 1024); broker.setPersistenceAdapter(kahadb); broker.addConnector("tcp://localhost:61656"); broker.getSystemUsage().getMemoryUsage().setLimit(256 * 1024 * 1024); broker.getSystemUsage().getTempUsage().setLimit(256 * 1024 * 1024); broker.getSystemUsage().getStoreUsage().setLimit(256 * 1024 * 1024); broker.start(); }
Example #11
Source File: DurableSubProcessMultiRestartTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void startBroker(boolean deleteAllMessages) throws Exception { if (broker != null) return; broker = BrokerFactory.createBroker("broker:(vm://" + getName() + ")"); broker.setBrokerName(getName()); broker.setAdvisorySupport(false); broker.setDeleteAllMessagesOnStartup(deleteAllMessages); broker.setKeepDurableSubsActive(true); File kahadbData = new File("activemq-data/" + getName() + "-kahadb"); if (deleteAllMessages) delete(kahadbData); broker.setPersistent(true); KahaDBPersistenceAdapter kahadb = new KahaDBPersistenceAdapter(); kahadb.setDirectory(kahadbData); kahadb.setJournalMaxFileLength(20 * 1024); broker.setPersistenceAdapter(kahadb); broker.addConnector("tcp://localhost:61656"); broker.getSystemUsage().getMemoryUsage().setLimit(256 * 1024 * 1024); broker.getSystemUsage().getTempUsage().setLimit(256 * 1024 * 1024); broker.getSystemUsage().getStoreUsage().setLimit(256 * 1024 * 1024); broker.start(); }
Example #12
Source File: DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void createBroker(boolean deleteAllMessages) throws Exception { broker = BrokerFactory.createBroker("broker:(vm://" + getName(true) + ")"); broker.setBrokerName(getName(true)); broker.setDeleteAllMessagesOnStartup(deleteAllMessages); broker.getManagementContext().setCreateConnector(false); broker.setAdvisorySupport(false); broker.addConnector("tcp://0.0.0.0:0"); setDefaultPersistenceAdapter(broker); ((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).getStore().getPageFile().setPageSize(1024); broker.start(); }
Example #13
Source File: DurableSubSelectorDelayTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void startBroker(boolean deleteAllMessages) throws Exception { if (broker != null) return; broker = BrokerFactory.createBroker("broker:(vm://" + getName() + ")"); broker.setBrokerName(getName()); broker.setAdvisorySupport(false); broker.setDeleteAllMessagesOnStartup(deleteAllMessages); File kahadbData = new File("activemq-data/" + getName() + "-kahadb"); if (deleteAllMessages) delete(kahadbData); broker.setPersistent(true); KahaDBPersistenceAdapter kahadb = new KahaDBPersistenceAdapter(); kahadb.setDirectory(kahadbData); kahadb.setJournalMaxFileLength(500 * 1024); broker.setPersistenceAdapter(kahadb); connectionUri = broker.addConnector("tcp://localhost:0").getPublishableConnectString(); broker.getSystemUsage().getMemoryUsage().setLimit(256 * 1024 * 1024); broker.getSystemUsage().getTempUsage().setLimit(256 * 1024 * 1024); broker.getSystemUsage().getStoreUsage().setLimit(256 * 1024 * 1024); broker.start(); }
Example #14
Source File: DurableSubSelectorDelayTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testProcess() throws Exception { MsgProducer msgProducer = new MsgProducer(); msgProducer.start(); DurableSubscriber subscribers[] = new DurableSubscriber[10]; for (int i = 0; i < subscribers.length; i++) { subscribers[i] = new DurableSubscriber(i); subscribers[i].process(); } // wait for server to finish msgProducer.join(); for (int j = 0; j < subscribers.length; j++) { LOG.info("Unsubscribing subscriber " + subscribers[j]); subscribers[j].unsubscribe(); } // allow the clean up thread time to run TimeUnit.MINUTES.sleep(2); final KahaDBPersistenceAdapter pa = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter(); assertTrue("less than two journal file should be left, was: " + pa.getStore().getJournal().getFileMap().size(), Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisified() throws Exception { return pa.getStore().getJournal().getFileMap().size() <= 2; } }, TimeUnit.MINUTES.toMillis(2))); LOG.info("DONE."); }
Example #15
Source File: DurableConsumerCloseAndReconnectTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected void createBroker() throws Exception { brokerService = new BrokerService(); brokerService.setUseJmx(false); brokerService.setPersistent(false); KahaDBPersistenceAdapter store = new KahaDBPersistenceAdapter(); brokerService.setPersistenceAdapter(store); brokerService.start(); brokerService.waitUntilStarted(); vmConnectorURI = brokerService.getVmConnectorURI().toString(); }
Example #16
Source File: ActivemqConfiguration.java From onetwo with Apache License 2.0 | 5 votes |
@Bean public PersistenceAdapter kahaDBPersistenceAdapter(){ KahaDBStoreProps kahaProps = activemqProperties.getKahadbStore(); // default messages store is under AMQ_HOME/data/KahaDB/ KahaDBPersistenceAdapter kahadb = new KahaDBPersistenceAdapter(); if(StringUtils.isNotBlank(kahaProps.getDataDir())){ File dataDir = new File(kahaProps.getDataDir()); if(!dataDir.exists()){ dataDir.mkdirs(); } kahadb.setDirectory(dataDir); } return kahadb; }
Example #17
Source File: DurableSubscriptionOfflineTestBase.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected void createBroker(boolean deleteAllMessages) throws Exception { String currentTestName = getName(true); broker = BrokerFactory.createBroker("broker:(vm://" + currentTestName + ")"); broker.setBrokerName(currentTestName); broker.setDeleteAllMessagesOnStartup(deleteAllMessages); broker.getManagementContext().setCreateConnector(false); broker.setAdvisorySupport(false); broker.setKeepDurableSubsActive(keepDurableSubsActive); broker.addConnector("tcp://0.0.0.0:0"); if (usePrioritySupport) { PolicyEntry policy = new PolicyEntry(); policy.setPrioritizedMessages(true); PolicyMap policyMap = new PolicyMap(); policyMap.setDefaultEntry(policy); broker.setDestinationPolicy(policyMap); } setDefaultPersistenceAdapter(broker); if (broker.getPersistenceAdapter() instanceof JDBCPersistenceAdapter) { // ensure it kicks in during tests ((JDBCPersistenceAdapter) broker.getPersistenceAdapter()).setCleanupPeriod(2 * 1000); } else if (broker.getPersistenceAdapter() instanceof KahaDBPersistenceAdapter) { // have lots of journal files ((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).setJournalMaxFileLength(journalMaxFileLength); } broker.start(); broker.waitUntilStarted(); }
Example #18
Source File: KahaDBSupportTest.java From tomee with Apache License 2.0 | 5 votes |
@Test public void create() throws Exception { final String path = "target/kahatest" + System.currentTimeMillis(); final BrokerService broker = BrokerFactory.createBroker(new URI("openejb:broker:(tcp://localhost:" + NetworkUtil.getNextAvailablePort() + ")?usekahadb=true&kahadb.directory=" + path)); try { assertThat(broker.getPersistenceAdapter(), instanceOf(KahaDBPersistenceAdapter.class)); final KahaDBPersistenceAdapter adapter = KahaDBPersistenceAdapter.class.cast(broker.getPersistenceAdapter()); assertEquals(new File(path), adapter.getDirectory()); } finally { broker.stop(); } }
Example #19
Source File: RecoverExpiredMessagesTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
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); }
Example #20
Source File: DurablePersistentFalseRestartTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void configureBroker(BrokerService broker) throws Exception { super.configureBroker(broker); broker.setPersistent(false); broker.setPersistenceAdapter(new KahaDBPersistenceAdapter()); broker.addConnector("tcp://0.0.0.0:0"); }
Example #21
Source File: kahaDbJdbcLeaseQueueMasterSlaveTest.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); 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(); }
Example #22
Source File: mKahaDbQueueMasterSlaveTest.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); MultiKahaDBPersistenceAdapter mKahaDB = new MultiKahaDBPersistenceAdapter(); List<FilteredKahaDBPersistenceAdapter> adapters = new LinkedList<>(); FilteredKahaDBPersistenceAdapter defaultEntry = new FilteredKahaDBPersistenceAdapter(); defaultEntry.setPersistenceAdapter(new KahaDBPersistenceAdapter()); defaultEntry.setPerDestination(true); adapters.add(defaultEntry); mKahaDB.setFilteredPersistenceAdapters(adapters); broker.setPersistenceAdapter(mKahaDB); broker.start(); slave.set(broker); slaveStarted.countDown(); } catch (IllegalStateException expectedOnShutdown) { } catch (Exception e) { fail("failed to start slave broker, reason:" + e); } } }; t.start(); }
Example #23
Source File: CheckDuplicateMessagesOnDuplexTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private PersistenceAdapter persistenceAdapterFactory_KahaDB(String path) { KahaDBPersistenceAdapter kahaDBPersistenceAdapter = new KahaDBPersistenceAdapter(); kahaDBPersistenceAdapter.setDirectory(new File(path)); kahaDBPersistenceAdapter.setIgnoreMissingJournalfiles(true); kahaDBPersistenceAdapter.setCheckForCorruptJournalFiles(true); kahaDBPersistenceAdapter.setChecksumJournalFiles(true); return kahaDBPersistenceAdapter; }
Example #24
Source File: KahaDBQueueTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void configureBroker(BrokerService answer, String uri) throws Exception { File dataFileDir = new File("target/test-amq-data/perfTest/kahadb"); File archiveDir = new File(dataFileDir, "archive"); KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter(); kaha.setDirectory(dataFileDir); kaha.setDirectoryArchive(archiveDir); kaha.setArchiveDataLogs(false); // The setEnableJournalDiskSyncs(false) setting is a little dangerous right now, as I have not verified // what happens if the index is updated but a journal update is lost. // Index is going to be in consistent, but can it be repaired? kaha.setEnableJournalDiskSyncs(true); // Using a bigger journal file size makes he take fewer spikes as it is not switching files as often. //kaha.setJournalMaxFileLength(1024*1024*100); // small batch means more frequent and smaller writes //kaha.setIndexWriteBatchSize(100); // do the index write in a separate thread kaha.setEnableIndexWriteAsync(true); kaha.setIndexCacheSize(10000); answer.setPersistenceAdapter(kaha); answer.addConnector(uri); answer.setDeleteAllMessagesOnStartup(true); }
Example #25
Source File: RunBroker.java From activemq-artemis with Apache License 2.0 | 5 votes |
public static void main(String arg[]) { try { KahaDBPersistenceAdapter kahaDB = new KahaDBPersistenceAdapter(); File dataFileDir = new File("target/test-amq-data/perfTest/kahadb"); IOHelper.deleteChildren(dataFileDir); kahaDB.setDirectory(dataFileDir); // The setEnableJournalDiskSyncs(false) setting is a little // dangerous right now, as I have not verified // what happens if the index is updated but a journal update is // lost. // Index is going to be in consistent, but can it be repaired? // kaha.setEnableJournalDiskSyncs(false); // Using a bigger journal file size makes he take fewer spikes as it // is not switching files as often. // kaha.setJournalMaxFileLength(1024*1024*100); // small batch means more frequent and smaller writes kahaDB.setIndexWriteBatchSize(1000); kahaDB.setIndexCacheSize(10000); // do the index write in a separate thread // kahaDB.setEnableIndexWriteAsync(true); BrokerService broker = new BrokerService(); broker.setUseJmx(false); // broker.setPersistenceAdapter(adaptor); broker.setPersistenceAdapter(kahaDB); // broker.setPersistent(false); broker.setDeleteAllMessagesOnStartup(true); broker.addConnector("tcp://0.0.0.0:61616"); broker.start(); System.err.println("Running"); Thread.sleep(Long.MAX_VALUE); } catch (Throwable e) { e.printStackTrace(); } }
Example #26
Source File: NetworkBrokerDetachTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
protected void configureBroker(BrokerService broker) throws Exception { KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter(); persistenceAdapter.setDirectory(new File("target/activemq-data/kahadb/" + broker.getBrokerName() + "NetworBrokerDetatchTest")); broker.setPersistenceAdapter(persistenceAdapter); }
Example #27
Source File: TestSupport.java From activemq-artemis with Apache License 2.0 | 4 votes |
public void stopBrokerWithStoreFailure(BrokerService broker, PersistenceAdapterChoice choice) throws Exception { switch (choice) { case KahaDB: KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter(); // have the broker stop with an IOException on next checkpoint so it has a pending local transaction to recover kahaDBPersistenceAdapter.getStore().getJournal().close(); break; default: // just stop normally by default broker.stop(); } broker.waitUntilStopped(); }
Example #28
Source File: ActiveMQQueueModule.java From james-project with Apache License 2.0 | 4 votes |
@Override protected void configure() { bind(PersistenceAdapter.class).to(KahaDBPersistenceAdapter.class); bind(KahaDBPersistenceAdapter.class).in(Scopes.SINGLETON); bind(EmbeddedActiveMQ.class).in(Scopes.SINGLETON); }
Example #29
Source File: DurableSubscriptionOfflineTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test(timeout = 60 * 1000) public void testRemovedDurableSubDeletesFromIndex() throws Exception { if (!(broker.getPersistenceAdapter() instanceof KahaDBPersistenceAdapter)) { return; } final int numMessages = 2750; KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter(); PageFile pageFile = kahaDBPersistenceAdapter.getStore().getPageFile(); LOG.info("PageCount " + pageFile.getPageCount() + " f:" + pageFile.getFreePageCount() + ", fileSize:" + pageFile.getFile().length()); long lastDiff = 0; for (int repeats = 0; repeats < 2; repeats++) { LOG.info("Iteration: " + repeats + " Count:" + pageFile.getPageCount() + " f:" + pageFile.getFreePageCount()); Connection con = createConnection("cliId1" + "-" + repeats); Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); session.createDurableSubscriber(topic, "SubsId", "filter = 'true'", true); session.close(); con.close(); // send messages con = createConnection(); session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(null); for (int i = 0; i < numMessages; i++) { Message message = session.createMessage(); message.setStringProperty("filter", "true"); producer.send(topic, message); } con.close(); Connection con2 = createConnection("cliId1" + "-" + repeats); Session session2 = con2.createSession(false, Session.AUTO_ACKNOWLEDGE); session2.unsubscribe("SubsId"); session2.close(); con2.close(); LOG.info("PageCount " + pageFile.getPageCount() + " f:" + pageFile.getFreePageCount() + " diff: " + (pageFile.getPageCount() - pageFile.getFreePageCount()) + " fileSize:" + pageFile.getFile().length()); if (lastDiff != 0) { assertEquals("Only use X pages per iteration: " + repeats, lastDiff, pageFile.getPageCount() - pageFile.getFreePageCount()); } lastDiff = pageFile.getPageCount() - pageFile.getFreePageCount(); } }
Example #30
Source File: DurableSubscriptionOffline4Test.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test(timeout = 60 * 1000) // https://issues.apache.org/jira/browse/AMQ-3206 public void testCleanupDeletedSubAfterRestart() throws Exception { Connection con = createConnection("cli1"); Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); session.createDurableSubscriber(topic, "SubsId", null, true); session.close(); con.close(); con = createConnection("cli2"); session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); session.createDurableSubscriber(topic, "SubsId", null, true); session.close(); con.close(); con = createConnection(); session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(null); final int toSend = 500; final String payload = Arrays.toString(new byte[40 * 1024]); int sent = 0; for (int i = sent; i < toSend; i++) { Message message = session.createTextMessage(payload); message.setStringProperty("filter", "false"); message.setIntProperty("ID", i); producer.send(topic, message); sent++; } con.close(); LOG.info("sent: " + sent); // kill off cli1 con = createConnection("cli1"); session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); session.unsubscribe("SubsId"); destroyBroker(); createBroker(false); con = createConnection("cli2"); session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createDurableSubscriber(topic, "SubsId", null, true); final DurableSubscriptionOfflineTestListener listener = new DurableSubscriptionOfflineTestListener(); consumer.setMessageListener(listener); assertTrue("got all sent", Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisified() throws Exception { LOG.info("Want: " + toSend + ", current: " + listener.count); return listener.count == toSend; } })); session.close(); con.close(); destroyBroker(); createBroker(false); final KahaDBPersistenceAdapter pa = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter(); assertTrue("Should have less than three journal files left but was: " + pa.getStore().getJournal().getFileMap().size(), Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisified() throws Exception { return pa.getStore().getJournal().getFileMap().size() <= 3; } })); }