Java Code Examples for org.apache.activemq.broker.BrokerService#setDataDirectoryFile()
The following examples show how to use
org.apache.activemq.broker.BrokerService#setDataDirectoryFile() .
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: 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 2
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 3
Source File: TestJmsSource.java From datacollector with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { baseDir = Files.createTempDir(); tmpDir = new File(baseDir, "tmp"); dataDir = new File(baseDir, "data"); Assert.assertTrue(tmpDir.mkdir()); passwordFile = new File(baseDir, "password"); Files.write(PASSWORD.getBytes(StandardCharsets.UTF_8), passwordFile); broker = new BrokerService(); broker.addConnector(BROKER_BIND_URL); broker.setTmpDataDirectory(tmpDir); broker.setDataDirectoryFile(dataDir); List<AuthenticationUser> users = Lists.newArrayList(); users.add(new AuthenticationUser(USERNAME, PASSWORD, "")); SimpleAuthenticationPlugin authentication = new SimpleAuthenticationPlugin(users); broker.setPlugins(new BrokerPlugin[]{authentication}); broker.start(); basicConfig = new BasicConfig(); credentialsConfig = new CredentialsConfig(); messageConfig = new MessageConfig(); jmsSourceConfig = new JmsSourceConfig(); credentialsConfig.useCredentials = true; credentialsConfig.username = () -> USERNAME; credentialsConfig.password = () -> PASSWORD; jmsSourceConfig.initialContextFactory = INITIAL_CONTEXT_FACTORY; jmsSourceConfig.connectionFactory = CONNECTION_FACTORY; jmsSourceConfig.destinationName = JNDI_PREFIX + DESTINATION_NAME; jmsSourceConfig.providerURL = BROKER_BIND_URL; // Create a connection and start ConnectionFactory factory = new ActiveMQConnectionFactory(USERNAME, PASSWORD, BROKER_BIND_URL); connection = factory.createConnection(); connection.start(); }
Example 4
Source File: TestJmsTarget.java From datacollector with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { baseDir = Files.createTempDir(); tmpDir = new File(baseDir, "tmp"); dataDir = new File(baseDir, "data"); Assert.assertTrue(tmpDir.mkdir()); passwordFile = new File(baseDir, "password"); Files.write(PASSWORD.getBytes(StandardCharsets.UTF_8), passwordFile); broker = new BrokerService(); broker.addConnector(BROKER_BIND_URL); broker.setTmpDataDirectory(tmpDir); broker.setDataDirectoryFile(dataDir); List<AuthenticationUser> users = Lists.newArrayList(); users.add(new AuthenticationUser(USERNAME, PASSWORD, "")); SimpleAuthenticationPlugin authentication = new SimpleAuthenticationPlugin(users); broker.setPlugins(new BrokerPlugin[]{authentication}); broker.start(); credentialsConfig = new CredentialsConfig(); jmsTargetConfig = new JmsTargetConfig(); credentialsConfig.useCredentials = true; credentialsConfig.username = () -> USERNAME; credentialsConfig.password = () -> PASSWORD; jmsTargetConfig.destinationName = JNDI_PREFIX + DESTINATION_NAME; jmsTargetConfig.initialContextFactory = INITIAL_CONTEXT_FACTORY; jmsTargetConfig.connectionFactory = CONNECTION_FACTORY; jmsTargetConfig.providerURL = BROKER_BIND_URL; // Create a connection and start ConnectionFactory factory = new ActiveMQConnectionFactory(USERNAME, PASSWORD, BROKER_BIND_URL); connection = factory.createConnection(); connection.start(); }
Example 5
Source File: LostScheduledMessagesTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void startBroker() throws Exception { broker = new BrokerService(); broker.setSchedulerSupport(true); broker.setPersistent(true); broker.setDeleteAllMessagesOnStartup(false); broker.setDataDirectory("target"); broker.setSchedulerDirectoryFile(schedulerDirectory); broker.setDataDirectoryFile(messageDirectory); broker.setUseJmx(false); broker.addConnector("vm://localhost"); broker.start(); }
Example 6
Source File: TestIntegrationActiveMQ.java From mt-flume with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Before public void setup() throws Exception { baseDir = Files.createTempDir(); tmpDir = new File(baseDir, "tmp"); dataDir = new File(baseDir, "data"); Assert.assertTrue(tmpDir.mkdir()); passwordFile = new File(baseDir, "password"); Files.write(PASSWORD.getBytes(Charsets.UTF_8), passwordFile); broker = new BrokerService(); broker.addConnector(BROKER_BIND_URL); broker.setTmpDataDirectory(tmpDir); broker.setDataDirectoryFile(dataDir); List<AuthenticationUser> users = Lists.newArrayList(); users.add(new AuthenticationUser(USERNAME, PASSWORD, "")); SimpleAuthenticationPlugin authentication = new SimpleAuthenticationPlugin(users); broker.setPlugins(new BrokerPlugin[]{authentication}); broker.start(); context = new Context(); context.put(JMSSourceConfiguration.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY); context.put(JMSSourceConfiguration.PROVIDER_URL, BROKER_BIND_URL); context.put(JMSSourceConfiguration.DESTINATION_NAME, DESTINATION_NAME); context.put(JMSSourceConfiguration.USERNAME, USERNAME); context.put(JMSSourceConfiguration.PASSWORD_FILE, passwordFile.getAbsolutePath()); events = Lists.newArrayList(); source = new JMSSource(); source.setName("JMSSource-" + UUID.randomUUID()); ChannelProcessor channelProcessor = mock(ChannelProcessor.class); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { events.addAll((List<Event>)invocation.getArguments()[0]); return null; } }).when(channelProcessor).processEventBatch(any(List.class)); source.setChannelProcessor(channelProcessor); }