org.apache.activemq.store.memory.MemoryPersistenceAdapter Java Examples
The following examples show how to use
org.apache.activemq.store.memory.MemoryPersistenceAdapter.
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: ExpiredMessagesTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
private BrokerService createBroker(boolean deleteAllMessages, long expireMessagesPeriod) throws Exception { BrokerService broker = new BrokerService(); broker.setBrokerName("localhost"); broker.setDestinations(new ActiveMQDestination[]{destination}); broker.setPersistenceAdapter(new MemoryPersistenceAdapter()); PolicyEntry defaultPolicy = new PolicyEntry(); if (useVMCursor) { defaultPolicy.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy()); } defaultPolicy.setExpireMessagesPeriod(expireMessagesPeriod); defaultPolicy.setMaxExpirePageSize(1200); PolicyMap policyMap = new PolicyMap(); policyMap.setDefaultEntry(defaultPolicy); broker.setDestinationPolicy(policyMap); broker.setDeleteAllMessagesOnStartup(deleteAllMessages); broker.addConnector("tcp://localhost:0"); broker.start(); broker.waitUntilStarted(); return broker; }
Example #2
Source File: CassandraStepdefs.java From james-project with Apache License 2.0 | 6 votes |
@Before public void init() throws Exception { cassandraServer.start(); temporaryFolder.create(); elasticSearch.start(); mainStepdefs.messageIdFactory = new CassandraMessageId.Factory(); Configuration configuration = Configuration.builder() .workingDirectory(temporaryFolder.newFolder()) .configurationFromClasspath() .build(); mainStepdefs.jmapServer = CassandraJamesServerMain.createServer(configuration) .overrideWith(new TestJMAPServerModule()) .overrideWith(new TestDockerESMetricReporterModule(elasticSearch.getDockerEs().getHttpHost())) .overrideWith(elasticSearch.getModule()) .overrideWith(cassandraServer.getModule()) .overrideWith(binder -> binder.bind(TextExtractor.class).to(DefaultTextExtractor.class)) .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class)) .overrideWith(binder -> Multibinder.newSetBinder(binder, CleanupTasksPerformer.CleanupTask.class).addBinding().to(CassandraTruncateTableTask.class)) .overrideWith((binder -> binder.bind(CleanupTasksPerformer.class).asEagerSingleton())); mainStepdefs.awaitMethod = () -> elasticSearch.getDockerEs().flushIndices(); mainStepdefs.init(); }
Example #3
Source File: JMSBrokerSetup.java From cxf with Apache License 2.0 | 6 votes |
public void run() { try { //ContainerWapper container; BrokerService broker = new BrokerService(); synchronized (this) { broker.setPersistenceAdapter(new MemoryPersistenceAdapter()); broker.setTmpDataDirectory(new File("./target")); broker.setPopulateJMSXUserID(true); broker.addConnector(brokerUrl); broker.setUseJmx(false); broker.start(); Thread.sleep(200); notifyAll(); } synchronized (this) { while (!shutdownBroker) { wait(1000); } } broker.stop(); broker = null; } catch (Exception e) { exception = e; e.printStackTrace(); } }
Example #4
Source File: EmbeddedJMSBrokerLauncher.java From cxf with Apache License 2.0 | 6 votes |
public final void run() { try { broker = new BrokerService(); broker.setPersistent(false); broker.setPersistenceAdapter(new MemoryPersistenceAdapter()); broker.setTmpDataDirectory(new File("./target")); broker.setUseJmx(false); if (brokerName != null) { broker.setBrokerName(brokerName); } broker.addConnector(brokerUrl1); broker.start(); } catch (Exception e) { e.printStackTrace(); } }
Example #5
Source File: EmbeddedActiveMQBroker.java From camel-cookbook-examples with Apache License 2.0 | 6 votes |
public EmbeddedActiveMQBroker(String brokerId) { Validate.notEmpty(brokerId, "brokerId is empty"); this.brokerId = brokerId; tcpConnectorUri = "tcp://localhost:" + AvailablePortFinder.getNextAvailable(); brokerService = new BrokerService(); brokerService.setBrokerId(brokerId); brokerService.setPersistent(false); brokerService.setUseJmx(false); try { brokerService.setPersistenceAdapter(new MemoryPersistenceAdapter()); brokerService.addConnector(tcpConnectorUri); } catch (Exception e) { throw new RuntimeException("Problem creating brokerService", e); } }
Example #6
Source File: JmsIOTest.java From beam with Apache License 2.0 | 5 votes |
@Before public void startBroker() throws Exception { broker = new BrokerService(); broker.setUseJmx(false); broker.setPersistenceAdapter(new MemoryPersistenceAdapter()); broker.addConnector(BROKER_URL); broker.setBrokerName("localhost"); broker.setPopulateJMSXUserID(true); broker.setUseAuthenticatedPrincipalForJMSXUserID(true); // enable authentication List<AuthenticationUser> users = new ArrayList<>(); // username and password to use to connect to the broker. // This user has users privilege (able to browse, consume, produce, list destinations) users.add(new AuthenticationUser(USERNAME, PASSWORD, "users")); SimpleAuthenticationPlugin plugin = new SimpleAuthenticationPlugin(users); BrokerPlugin[] plugins = new BrokerPlugin[] {plugin}; broker.setPlugins(plugins); broker.start(); // create JMS connection factory connectionFactory = new ActiveMQConnectionFactory(BROKER_URL); connectionFactoryWithSyncAcksAndWithoutPrefetch = new ActiveMQConnectionFactory( BROKER_URL + "?jms.prefetchPolicy.all=0&jms.sendAcksAsync=false"); }
Example #7
Source File: ConfigTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testMemoryConfig() throws Exception { File journalFile = new File(JOURNAL_ROOT + "testMemoryConfig"); recursiveDelete(journalFile); File derbyFile = new File(DERBY_ROOT + "testMemoryConfig"); recursiveDelete(derbyFile); BrokerService broker; broker = createBroker(new FileSystemResource(CONF_ROOT + "memory-example.xml")); try { assertEquals("Broker Config Error (brokerName)", "brokerMemoryConfigTest", broker.getBrokerName()); PersistenceAdapter adapter = broker.getPersistenceAdapter(); assertTrue("Should have created a memory persistence adapter", adapter instanceof MemoryPersistenceAdapter); assertTrue("Should have not created a derby directory at " + derbyFile.getAbsolutePath(), !derbyFile.exists()); assertTrue("Should have not created a journal directory at " + journalFile.getAbsolutePath(), !journalFile.exists()); LOG.info("Success"); } finally { if (broker != null) { broker.stop(); } } }
Example #8
Source File: TemporaryJamesServer.java From james-project with Apache License 2.0 | 5 votes |
private TemporaryJamesServer(File workingDir, MailetContainer mailetContainer, SmtpConfiguration smtpConfiguration, Module serverBaseModule, List<Module> additionalModules) throws Exception { appendMailetConfigurations(workingDir, mailetContainer); appendSmtpConfigurations(workingDir, smtpConfiguration); Configuration configuration = Configuration.builder().workingDirectory(workingDir).build(); copyResources(Paths.get(workingDir.getAbsolutePath(), "conf")); jamesServer = GuiceJamesServer.forConfiguration(configuration) .combineWith(serverBaseModule) .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class)) .overrideWith(additionalModules) .overrideWith(new TestJMAPServerModule()) .overrideWith((binder) -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION)); }
Example #9
Source File: RabbitMQAwsS3Stepdefs.java From james-project with Apache License 2.0 | 5 votes |
@Before public void init() throws Exception { cassandraServer.start(); rabbitMQServer.start(); swiftServer.start(); elasticSearch.start(); temporaryFolder.create(); mainStepdefs.messageIdFactory = new CassandraMessageId.Factory(); CassandraRabbitMQJamesConfiguration configuration = CassandraRabbitMQJamesConfiguration.builder() .workingDirectory(temporaryFolder.newFolder()) .configurationFromClasspath() .blobStore(BlobStoreConfiguration.objectStorage().disableCache()) .build(); mainStepdefs.jmapServer = CassandraRabbitMQJamesServerMain.createServer(configuration) .overrideWith(new TestJMAPServerModule()) .overrideWith(new TestDockerESMetricReporterModule(elasticSearch.getDockerEs().getHttpHost())) .overrideWith(new TestRabbitMQModule(rabbitMQServer.dockerRabbitMQ())) .overrideWith(swiftServer.getModule()) .overrideWith(elasticSearch.getModule()) .overrideWith(cassandraServer.getModule()) .overrideWith(binder -> binder.bind(TextExtractor.class).to(DefaultTextExtractor.class)) .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class)) .overrideWith(binder -> Multibinder.newSetBinder(binder, CleanupTasksPerformer.CleanupTask.class).addBinding().to(CassandraTruncateTableTask.class)) .overrideWith((binder -> binder.bind(CleanupTasksPerformer.class).asEagerSingleton())); mainStepdefs.awaitMethod = () -> elasticSearch.getDockerEs().flushIndices(); mainStepdefs.init(); }
Example #10
Source File: JmsCollectorTest.java From karaf-decanter with Apache License 2.0 | 5 votes |
@BeforeClass public static void startBroker() throws Exception { broker = new BrokerService(); broker.setPersistenceAdapter(new MemoryPersistenceAdapter()); broker.addConnector("tcp://localhost:61616"); broker.setUseJmx(false); broker.start(); }
Example #11
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 #12
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 #13
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 #14
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 #15
Source File: AbstractJMSTester.java From cxf with Apache License 2.0 | 5 votes |
@BeforeClass public static void startSerices() throws Exception { broker = new BrokerService(); broker.setPersistent(false); broker.setPopulateJMSXUserID(true); broker.setUseAuthenticatedPrincipalForJMSXUserID(true); broker.setUseJmx(false); broker.setPersistenceAdapter(new MemoryPersistenceAdapter()); String brokerUri = "tcp://localhost:" + TestUtil.getNewPortNumber(AbstractJMSTester.class); broker.addConnector(brokerUri); broker.start(); bus = BusFactory.getDefaultBus(); cf1 = new ActiveMQConnectionFactory(brokerUri); cf = cf1; }
Example #16
Source File: OpenEjbBrokerFactoryTest.java From tomee with Apache License 2.0 | 5 votes |
public void testNoDataSource() throws Exception { final BrokerService broker = BrokerFactory.createBroker(new URI(getBrokerUri( "broker:(tcp://localhost:" + brokerPort + ")?useJmx=false"))); assertNotNull("broker is null", broker); final PersistenceAdapter persistenceAdapter = broker.getPersistenceAdapter(); assertNotNull("persistenceAdapter is null", persistenceAdapter); assertTrue("persistenceAdapter should be an instance of MemoryPersistenceAdapter", persistenceAdapter instanceof MemoryPersistenceAdapter); stopBroker(broker); }