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


Java BrokerFactory类代码示例

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


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

示例1: testRollbackXaErrorCode

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

示例2: testCreatePartitionBroker

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

   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:23,代码来源:SpringPartitionBrokerTest.java

示例3: createBroker

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

示例4: startBroker

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

示例5: startBroker

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

示例6: 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

示例7: initialize

import org.apache.activemq.broker.BrokerFactory; //导入依赖的package包/类
@Override
public void initialize() {
    super.initialize();
    try {
        if (_config == null) {
            _broker = new BrokerService();
            _broker.setStartAsync(true);
            _broker.setBrokerName("default");
            _broker.setUseJmx(false);
            _broker.setPersistent(false);
            _broker.setDataDirectoryFile(new File(System.getProperty("java.io.tmpdir"), "activemq-data"));
            _broker.addConnector(ActiveMQConnectionFactory.DEFAULT_BROKER_BIND_URL);
            _broker.setUseShutdownHook(false);
        } else {
            _broker = BrokerFactory.createBroker(_config);
        }

        _broker.start();
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:23,代码来源:ActiveMQMixIn.java

示例8: 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

示例9: execute

import org.apache.activemq.broker.BrokerFactory; //导入依赖的package包/类
public void execute() throws Exception {
    if (config == null) {
        throw new Exception("required --config option missing");
    }
    if (file == null) {
        throw new Exception("required --file option missing");
    }
    System.out.println("Loading: " + config);
    BrokerFactory.setStartDefault(false); // to avoid the broker auto-starting..
    BrokerService broker = BrokerFactory.createBroker(config);
    BrokerFactory.resetStartDefault();
    PersistenceAdapter store = broker.getPersistenceAdapter();
    System.out.println("Starting: " + store);
    store.start();
    try {
        BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(file));
        try {
            export(store, fos);
        } finally {
            fos.close();
        }
    } finally {
        store.stop();
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:26,代码来源:StoreExporter.java

示例10: setup

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

示例11: setup

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

示例12: setup

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

示例13: setup

import org.apache.activemq.broker.BrokerFactory; //导入依赖的package包/类
@Before
public void setup() throws Exception {
   System.setProperty("ldapPort", String.valueOf(getLdapServer().getPort()));

   broker = BrokerFactory.createBroker("xbean:org/apache/activemq/security/activemq-ldap-auth.xml");
   broker.start();
   broker.waitUntilStarted();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:LDAPAuthenticationTest.java

示例14: setUp

import org.apache.activemq.broker.BrokerFactory; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
   System.setProperty("java.security.auth.login.config", "src/test/resources/login.config");
   broker1 = BrokerFactory.createBroker(new URI("xbean:org/apache/activemq/security/broker1.xml"));
   broker2 = BrokerFactory.createBroker(new URI("xbean:org/apache/activemq/security/broker2.xml"));
   broker1.waitUntilStarted();
   broker2.waitUntilStarted();
   Thread.sleep(2000);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:10,代码来源:JaasNetworkTest.java

示例15: 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


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