当前位置: 首页>>代码示例>>Java>>正文


Java BrokerFactory.createBroker方法代码示例

本文整理汇总了Java中org.apache.activemq.broker.BrokerFactory.createBroker方法的典型用法代码示例。如果您正苦于以下问题:Java BrokerFactory.createBroker方法的具体用法?Java BrokerFactory.createBroker怎么用?Java BrokerFactory.createBroker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.activemq.broker.BrokerFactory的用法示例。


在下文中一共展示了BrokerFactory.createBroker方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createBroker

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:17,代码来源:StartAndStopBrokerTest.java

示例2: createBroker

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
@Override
// TODO throw corresponding exceptions, not just Exception instances.
protected BrokerService createBroker(ServletContext sc) throws Exception {
	// Initialize Web environment to make Spring resolve external
	// properties.
	StandardServletEnvironment standardServletEnvironment = new ReversePropertySourcesStandardServletEnvironment();
	WebApplicationContextUtils.initServletPropertySources(standardServletEnvironment.getPropertySources(), sc);

	URI configURI = new URI(standardServletEnvironment.getProperty(BROKER_URI_PROP));

	LOG.info("Loading message broker from: " + configURI);
	return BrokerFactory.createBroker(configURI);
}
 
开发者ID:Hevelian,项目名称:hevelian-activemq,代码行数:14,代码来源:WebBrokerInitializerImpl.java

示例3: createBroker

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
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();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:11,代码来源:TopicDurableConnectStatsTest.java

示例4: createBroker

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
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();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:15,代码来源:DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.java

示例5: startBroker

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
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();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:15,代码来源:ManagedDurableSubscriptionTest.java

示例6: createBroker

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
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();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:12,代码来源:DurableSubsOfflineSelectorIndexUseTest.java

示例7: startBroker

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
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();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:12,代码来源:BrowseDLQTest.java

示例8: testCloseSendConnection

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
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();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:28,代码来源:ActiveMQXAConnectionFactoryTest.java

示例9: createBroker

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
public static BrokerService createBroker() throws Exception {
    BrokerService b = null;
    if (LOCAL_BROKER) {
        b = BrokerFactory.createBroker("broker:(" + bindAddress + ")/EXAMPLE?persistent=false&useJmx=false&deleteAllMessagesOnStartup=true");
        b.start();
    }
    return b;
}
 
开发者ID:hzbarcea,项目名称:activemq-samples,代码行数:9,代码来源:SimpleTrafficTest.java

示例10: createBroker

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
public static BrokerService createBroker(String name) throws Exception {
	BrokerService b = BrokerFactory.createBroker("xbean:META-INF/org/apache/activemq/" + name + ".xml");
	if (!name.equals(b.getBrokerName())) {
		LOG.warn("Broker name mismatch (expecting '{}'). Check configuration.", name);
		return null;
	}
    BROKERS.add(b);
    b.start();
    b.waitUntilStarted();
    return b;
}
 
开发者ID:hzbarcea,项目名称:activemq-samples,代码行数:12,代码来源:ClusterTest.java

示例11: createNewBroker

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
public static BrokerService createNewBroker() throws Exception {
	int index = BROKERS.size();
	int port = PORT_START + index;
	String bindAddress = "tcp://localhost:" + port;
	String name = "BROKER-" + index;

	BrokerService b = BrokerFactory.createBroker("broker:(" + bindAddress + ")/" + name + "?persistent=false&useJmx=true&deleteAllMessagesOnStartup=true");
    BROKERS.add(b);
    b.start();
    return b;
}
 
开发者ID:hzbarcea,项目名称:activemq-samples,代码行数:12,代码来源:DestinationFenceTest.java

示例12: before

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
public void before() throws Exception {

        service = BrokerFactory.createBroker("xbean:activemq.xml");
        service.start();

        connectionFactory = new ActiveMQConnectionFactory(connectionUri);
        connection = connectionFactory.createConnection();
        connection.start();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        destination = session.createQueue("MyQueue");
    }
 
开发者ID:tabish121,项目名称:ActiveMQ-HowTo,代码行数:12,代码来源:EmbeddedSimpleJMS.java

示例13: testBrokerDoubleCreate

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
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);

}
 
开发者ID:apache,项目名称:tomee,代码行数:9,代码来源:OpenEjbBrokerFactoryTest.java

示例14: testNoDataSource

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:tomee,代码行数:14,代码来源:OpenEjbBrokerFactoryTest.java

示例15: testDirectDataSource

import org.apache.activemq.broker.BrokerFactory; //导入方法依赖的package包/类
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);
        }
    }
 
开发者ID:apache,项目名称:tomee,代码行数:35,代码来源:OpenEjbBrokerFactoryTest.java


注:本文中的org.apache.activemq.broker.BrokerFactory.createBroker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。