Java Code Examples for org.apache.activemq.broker.BrokerService#setPersistenceAdapter()
The following examples show how to use
org.apache.activemq.broker.BrokerService#setPersistenceAdapter() .
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: EmbeddedActiveMQ.java From james-project with Apache License 2.0 | 6 votes |
private void launchEmbeddedBroker(FileSystem fileSystem) throws Exception { brokerService = new BrokerService(); brokerService.setBrokerName(BROKER_NAME); brokerService.setUseJmx(false); brokerService.setPersistent(true); brokerService.setDataDirectoryFile(fileSystem.getFile(BROCKERS_LOCATION)); brokerService.setUseShutdownHook(false); brokerService.setSchedulerSupport(false); brokerService.setBrokerId(BROKER_ID); String[] uris = {BROCKER_URI}; brokerService.setTransportConnectorURIs(uris); ManagementContext managementContext = new ManagementContext(); managementContext.setCreateConnector(false); brokerService.setManagementContext(managementContext); brokerService.setPersistenceAdapter(persistenceAdapter); BrokerPlugin[] brokerPlugins = {new StatisticsBrokerPlugin()}; brokerService.setPlugins(brokerPlugins); String[] transportConnectorsURIs = {BROCKER_URI}; brokerService.setTransportConnectorURIs(transportConnectorsURIs); brokerService.start(); LOGGER.info("Started embedded activeMq"); }
Example 2
Source File: BrokerNetworkWithStuckMessagesTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
protected BrokerService createSecondRemoteBroker() throws Exception { secondRemoteBroker = new BrokerService(); secondRemoteBroker.setBrokerName("secondRemotehost"); secondRemoteBroker.setUseJmx(false); secondRemoteBroker.setPersistenceAdapter(null); secondRemoteBroker.setPersistent(false); secondRemoteConnector = createSecondRemoteConnector(); secondRemoteBroker.addConnector(secondRemoteConnector); configureBroker(secondRemoteBroker); secondRemoteBroker.start(); secondRemoteBroker.waitUntilStarted(); brokers.put(secondRemoteBroker.getBrokerName(), secondRemoteBroker); return secondRemoteBroker; }
Example 3
Source File: BrokerNetworkWithStuckMessagesTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
protected BrokerService createRemoteBroker() throws Exception { remoteBroker = new BrokerService(); remoteBroker.setBrokerName("remotehost"); remoteBroker.setUseJmx(true); remoteBroker.setPersistenceAdapter(null); remoteBroker.setPersistent(false); remoteConnector = createRemoteConnector(); remoteBroker.addConnector(remoteConnector); configureBroker(remoteBroker); remoteBroker.start(); remoteBroker.waitUntilStarted(); remoteBroker.getManagementContext().setConnectorPort(2222); brokers.put(remoteBroker.getBrokerName(), remoteBroker); return remoteBroker; }
Example 4
Source File: QueueBrowsingLevelDBTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public BrokerService createBroker() throws IOException { BrokerService broker = super.createBroker(); LevelDBStore store = new LevelDBStore(); store.setDirectory(new File("target/test-data/leveldb")); broker.setPersistenceAdapter(store); return broker; }
Example 5
Source File: DurableSubscriptionTestSupport.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void createRestartedBroker() throws Exception { broker = new BrokerService(); broker.setBrokerName("durable-broker"); broker.setDeleteAllMessagesOnStartup(false); broker.setPersistenceAdapter(createPersistenceAdapter()); broker.setPersistent(true); broker.start(); broker.waitUntilStarted(); connection = createConnection(); }
Example 6
Source File: DurableSubscriptionTestSupport.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void createBroker() throws Exception { broker = new BrokerService(); broker.setBrokerName("durable-broker"); broker.setDeleteAllMessagesOnStartup(true); broker.setPersistenceAdapter(createPersistenceAdapter()); broker.setPersistent(true); broker.start(); broker.waitUntilStarted(); connection = createConnection(); }
Example 7
Source File: DbRestartJDBCQueueTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@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(); }
Example 8
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 9
Source File: QueueConnectionMemoryTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void configureBroker(BrokerService answer, String uri) throws Exception { LevelDBStore adaptor = new LevelDBStore(); answer.setPersistenceAdapter(adaptor); answer.addConnector(uri); answer.setDeleteAllMessagesOnStartup(true); }
Example 10
Source File: AbstractVmJMSTest.java From cxf with Apache License 2.0 | 5 votes |
public static void startBroker(String brokerURI) { broker = new BrokerService(); broker.setPersistent(false); try { broker.setPersistenceAdapter(new MemoryPersistenceAdapter()); broker.setTmpDataDirectory(new File("./target")); broker.setUseJmx(false); broker.addConnector(brokerURI); broker.start(); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
Example 11
Source File: DurableSubscriptionReactivationTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected BrokerService createBroker() throws Exception { BrokerService answer = super.createBroker(); answer.setKeepDurableSubsActive(keepDurableSubsActive); answer.setPersistenceAdapter(new JDBCPersistenceAdapter()); answer.setDeleteAllMessagesOnStartup(true); return answer; }
Example 12
Source File: SingleBrokerVirtualDestinationsWithWildcardLevelDBTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void configurePersistenceAdapter(BrokerService broker) throws IOException { File dataFileDir = new File("target/test-amq-data/leveldb/" + broker.getBrokerName()); LevelDBStore kaha = new LevelDBStore(); kaha.setDirectory(dataFileDir); broker.setPersistenceAdapter(kaha); }
Example 13
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 14
Source File: MqttCollectorTest.java From karaf-decanter with Apache License 2.0 | 5 votes |
@BeforeClass public static void startBroker() throws Exception { broker = new BrokerService(); broker.setUseJmx(false); broker.setPersistenceAdapter(new MemoryPersistenceAdapter()); broker.addConnector(new URI("mqtt://localhost:11883")); broker.start(); }
Example 15
Source File: EmbeddedBroker.java From cxf with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { BrokerService broker = new BrokerService(); broker.setPersistenceAdapter(new MemoryPersistenceAdapter()); broker.setDataDirectory("target/activemq-data"); broker.addConnector("tcp://localhost:61616"); broker.start(); System.out.println("JMS broker ready ..."); Thread.sleep(125 * 60 * 1000); System.out.println("JMS broker exiting"); broker.stop(); System.exit(0); }
Example 16
Source File: TwoBrokerVirtualDestDinamicallyIncludedDestTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected void configurePersistenceAdapter(BrokerService broker) throws IOException { File dataFileDir = new File("target/test-amq-data/kahadb/" + broker.getBrokerName()); KahaDBStore kaha = new KahaDBStore(); kaha.setDirectory(dataFileDir); kaha.deleteAllMessages(); broker.setPersistenceAdapter(kaha); }
Example 17
Source File: ThreeBrokerVirtualTopicNetworkLevelDBTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void configurePersistenceAdapter(BrokerService broker) throws IOException { File dataFileDir = new File("target/test-data/leveldb/" + broker.getBrokerName()); LevelDBStore adapter = new LevelDBStore(); adapter.setDirectory(dataFileDir); broker.setPersistenceAdapter(adapter); }
Example 18
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 19
Source File: LevelDBStoreBrokerTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Override protected BrokerService createBroker() throws Exception { BrokerService broker = new BrokerService(); broker.setPersistenceAdapter(createPersistenceAdapter(true)); return broker; }
Example 20
Source File: QpidJmsTestSupport.java From qpid-jms with Apache License 2.0 | 4 votes |
protected BrokerService createBroker(String name, boolean deleteAllMessages, Map<String, Integer> portMap) throws Exception { BrokerService brokerService = new BrokerService(); brokerService.setBrokerName(name); brokerService.setPersistent(isPersistent()); brokerService.setSchedulerSupport(isSchedulerSupport()); brokerService.setAdvisorySupport(isAdvisorySupport()); brokerService.setDeleteAllMessagesOnStartup(deleteAllMessages); brokerService.setUseJmx(true); brokerService.getManagementContext().setCreateConnector(false); brokerService.setDataDirectory("target/" + name); brokerService.setKeepDurableSubsActive(false); if (isPersistent()) { KahaDBStore kaha = new KahaDBStore(); kaha.setDirectory(new File(KAHADB_DIRECTORY + "/" + name)); kaha.setConcurrentStoreAndDispatchQueues(isConcurrentStoreAndDispatchQueues()); kaha.setConcurrentStoreAndDispatchTopics(isConcurrentStoreAndDispatchTopics()); kaha.setCheckpointInterval(TimeUnit.MINUTES.toMillis(5)); brokerService.setPersistenceAdapter(kaha); } configureBrokerPolicies(brokerService); ArrayList<BrokerPlugin> plugins = new ArrayList<BrokerPlugin>(); BrokerPlugin authenticationPlugin = configureAuthentication(); if (authenticationPlugin != null) { plugins.add(authenticationPlugin); } BrokerPlugin authorizationPlugin = configureAuthorization(); if (authorizationPlugin != null) { plugins.add(authorizationPlugin); } addAdditionalBrokerPlugins(plugins); if (!plugins.isEmpty()) { BrokerPlugin[] array = new BrokerPlugin[plugins.size()]; brokerService.setPlugins(plugins.toArray(array)); } addAdditionalConnectors(brokerService, portMap); return brokerService; }