org.apache.activemq.broker.BrokerFactory Java Examples
The following examples show how to use
org.apache.activemq.broker.BrokerFactory.
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: 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 #2
Source File: SpringPartitionBrokerTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
public void testCreatePartitionBroker() throws Exception { BrokerService broker = BrokerFactory.createBroker("xbean:activemq-partition.xml"); assertEquals(1, broker.getPlugins().length); PartitionBrokerPlugin plugin = (PartitionBrokerPlugin) broker.getPlugins()[0]; Partitioning config = plugin.getConfig(); assertEquals(2, config.getBrokers().size()); String json = "{\n" + " \"by_client_id\":{\n" + " \"client1\":{\"ids\":[\"broker1\"]},\n" + " \"client2\":{\"ids\":[\"broker1\",\"broker2\"]}\n" + " },\n" + " \"brokers\":{\n" + " \"broker1\":\"tcp://localhost:61616\",\n" + " \"broker2\":\"tcp://localhost:61616\"\n" + " }\n" + "}"; Partitioning expected = Partitioning.MAPPER.readValue(json, Partitioning.class); assertEquals(expected.toString(), config.toString()); }
Example #3
Source File: ActiveMQXAConnectionFactoryTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
public void testRollbackXaErrorCode() throws Exception { String brokerName = "rollbackErrorCode"; BrokerService broker = BrokerFactory.createBroker(new URI("broker:(tcp://localhost:0)/" + brokerName)); broker.start(); broker.waitUntilStarted(); ActiveMQXAConnectionFactory cf = new ActiveMQXAConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri()); XAConnection connection = (XAConnection) cf.createConnection(); connection.start(); XASession session = connection.createXASession(); XAResource resource = session.getXAResource(); Xid tid = createXid(); try { resource.rollback(tid); fail("Expected xa exception on no tx"); } catch (XAException expected) { LOG.info("got expected xa", expected); assertEquals("no tx", XAException.XAER_NOTA, expected.errorCode); } connection.close(); broker.stop(); }
Example #4
Source File: StartAndStopBrokerTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
protected BrokerService createBroker() throws JMSException { BrokerService broker = null; try { broker = BrokerFactory.createBroker(new URI("broker://()/localhost")); broker.setBrokerName("DefaultBroker"); broker.addConnector("tcp://localhost:9100"); broker.setUseShutdownHook(false); broker.start(); } catch (Exception e) { e.printStackTrace(); } return broker; }
Example #5
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 #6
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 #7
Source File: DurableSubsOfflineSelectorIndexUseTest.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); broker.start(); }
Example #8
Source File: BrokerPropertiesTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
public void testPropertiesFile() throws Exception { BrokerService broker = BrokerFactory.createBroker("properties:org/apache/activemq/config/broker.properties"); LOG.info("Created broker: " + broker); assertNotNull(broker); assertEquals("isUseJmx()", false, broker.isUseJmx()); assertEquals("isPersistent()", false, broker.isPersistent()); assertEquals("getBrokerName()", "Cheese", broker.getBrokerName()); broker.stop(); }
Example #9
Source File: CachedLDAPSecurityTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Before @Override public void setup() throws Exception { System.setProperty("ldapPort", String.valueOf(getLdapServer().getPort())); broker = BrokerFactory.createBroker("xbean:org/apache/activemq/security/activemq-apacheds.xml"); broker.start(); broker.waitUntilStarted(); }
Example #10
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 #11
Source File: LDAPSecurityTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { System.setProperty("ldapPort", String.valueOf(getLdapServer().getPort())); broker = BrokerFactory.createBroker("xbean:org/apache/activemq/security/activemq-ldap.xml"); broker.start(); broker.waitUntilStarted(); }
Example #12
Source File: CachedLDAPSecurityLegacyTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { System.setProperty("ldapPort", String.valueOf(getLdapServer().getPort())); broker = BrokerFactory.createBroker("xbean:org/apache/activemq/security/activemq-apacheds-legacy.xml"); broker.start(); broker.waitUntilStarted(); }
Example #13
Source File: OpenEjbBrokerFactoryTest.java From tomee with Apache License 2.0 | 5 votes |
public void testDirectDataSource() throws Exception { final Properties properties = new Properties(); final JDBCDataSource dataSource = new JDBCDataSource(); dataSource.setDatabase("jdbc:hsqldb:mem:testdb" + System.currentTimeMillis()); dataSource.setUser("sa"); dataSource.setPassword(""); dataSource.getConnection().close(); properties.put("DataSource", dataSource); properties.put("UseDatabaseLock", "false"); properties.put("StartupTimeout", "10000"); ActiveMQFactory.setThreadProperties(properties); BrokerService broker = null; try { 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 JDBCPersistenceAdapter", persistenceAdapter instanceof JDBCPersistenceAdapter); final JDBCPersistenceAdapter jdbcPersistenceAdapter = (JDBCPersistenceAdapter) persistenceAdapter; assertSame(dataSource, jdbcPersistenceAdapter.getDataSource()); } finally { stopBroker(broker); ActiveMQFactory.setThreadProperties(null); } }
Example #14
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); }
Example #15
Source File: OpenEjbBrokerFactoryTest.java From tomee with Apache License 2.0 | 5 votes |
public void testBrokerDoubleCreate() throws Exception { BrokerService broker = BrokerFactory.createBroker(new URI(getBrokerUri("broker:(tcp://localhost:" + brokerPort + ")?useJmx=false"))); stopBroker(broker); broker = BrokerFactory.createBroker(new URI(getBrokerUri("broker:(tcp://localhost:" + brokerPort + ")?useJmx=false"))); stopBroker(broker); }
Example #16
Source File: ActiveMQXAConnectionFactoryTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
public void testCloseSendConnection() throws Exception { String brokerName = "closeSend"; BrokerService broker = BrokerFactory.createBroker(new URI("broker:(tcp://localhost:0)/" + brokerName)); broker.start(); broker.waitUntilStarted(); ActiveMQXAConnectionFactory cf = new ActiveMQXAConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri()); XAConnection connection = (XAConnection) cf.createConnection(); connection.start(); XASession session = connection.createXASession(); XAResource resource = session.getXAResource(); Destination dest = new ActiveMQQueue(getName()); // publish a message Xid tid = createXid(); resource.start(tid, XAResource.TMNOFLAGS); MessageProducer producer = session.createProducer(dest); ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setText(getName()); producer.send(message); connection.close(); //comment out this check as it doesn't apply to artemis //assertTransactionGoneFromBroker(tid); broker.stop(); }
Example #17
Source File: JmsMultipleBrokersTestSupport.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected BrokerService createBroker(URI brokerUri) throws Exception { BrokerService broker = BrokerFactory.createBroker(brokerUri); configureBroker(broker); brokers.put(broker.getBrokerName(), new BrokerItem(broker)); return broker; }
Example #18
Source File: ReliableReconnectTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected void startBroker(boolean deleteOnStart) throws JMSException { try { broker = BrokerFactory.createBroker(new URI("broker://()/localhost")); broker.setUseShutdownHook(false); broker.setDeleteAllMessagesOnStartup(deleteOnStart); broker.setUseJmx(false); broker.addConnector(DEFAULT_BROKER_URL); broker.start(); } catch (Exception e) { e.printStackTrace(); } }
Example #19
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 #20
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 #21
Source File: BrowseDLQTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void startBroker() throws Exception { brokerService = BrokerFactory.createBroker("broker:()/localhost?deleteAllMessagesOnStartup=true"); PolicyMap policyMap = new PolicyMap(); PolicyEntry policyEntry = new PolicyEntry(); policyEntry.setExpireMessagesPeriod(1000); policyMap.setDefaultEntry(policyEntry); brokerService.setDestinationPolicy(policyMap); brokerService.start(); brokerService.waitUntilStarted(); }
Example #22
Source File: AuthorizationFromAdminViewTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void createBroker() throws Exception { broker = BrokerFactory.createBroker("broker:(vm://localhost)"); broker.setPersistent(false); broker.setBrokerName(getName()); AuthorizationPlugin plugin = new AuthorizationPlugin(); plugin.setMap(new SimpleAuthorizationMap()); BrokerPlugin[] plugins = new BrokerPlugin[]{plugin}; broker.setPlugins(plugins); broker.start(); }
Example #23
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 #24
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 #25
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 #26
Source File: ManagedDurableSubscriptionTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void startBroker() throws Exception { broker = BrokerFactory.createBroker("broker:(vm://localhost)"); broker.setKeepDurableSubsActive(false); broker.setPersistent(true); LevelDBStore persistenceAdapter = new LevelDBStore(); persistenceAdapter.setDirectory(new File("activemq-data/" + getName())); broker.setPersistenceAdapter(persistenceAdapter); broker.setUseJmx(true); broker.getManagementContext().setCreateConnector(false); broker.setBrokerName(getName()); broker.start(); connection = createConnection(); }
Example #27
Source File: DurableUnsubscribeTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void createBroker() throws Exception { broker = BrokerFactory.createBroker("broker:(vm://localhost)"); //broker.setPersistent(false); broker.setUseJmx(true); broker.setBrokerName(getName()); broker.deleteAllMessages(); broker.start(); connection = createConnection(); }
Example #28
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 #29
Source File: AdvisoryTopicDeletionTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void createBroker() throws Exception { broker = BrokerFactory.createBroker("broker:(vm://localhost)"); broker.setPersistent(false); broker.setBrokerName(getName()); broker.start(); connection = createConnection(); }
Example #30
Source File: TopicDurableConnectStatsTest.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.setAdvisorySupport(false); broker.addConnector("tcp://0.0.0.0:0"); setDefaultPersistenceAdapter(broker); broker.start(); }