當前位置: 首頁>>代碼示例>>Java>>正文


Java BrokerService.start方法代碼示例

本文整理匯總了Java中org.apache.activemq.broker.BrokerService.start方法的典型用法代碼示例。如果您正苦於以下問題:Java BrokerService.start方法的具體用法?Java BrokerService.start怎麽用?Java BrokerService.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.activemq.broker.BrokerService的用法示例。


在下文中一共展示了BrokerService.start方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startBroker

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@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);
  connectionFactoryWithoutPrefetch =
      new ActiveMQConnectionFactory(BROKER_URL + "?jms.prefetchPolicy.all=0");
}
 
開發者ID:apache,項目名稱:beam,代碼行數:27,代碼來源:JmsIOTest.java

示例2: start

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
/**
 * @param The activemq connector uri, for instance: "failover:(tcp://localhost:61616)?startupMaxReconnectAttempts=3"
 *        The failover:() is stipped out so that a tcp:// uri is created for the server.
 */
@Override
public URI start(String suggestedURI) throws EventException {

	try {
		Pattern pattern = Pattern.compile(".*(tcp://[a-zA-Z\\.]+:\\d+).*");
		Matcher matcher = pattern.matcher(suggestedURI);
		if (matcher.matches()) suggestedURI = matcher.group(1);

		URI uri = new URI(suggestedURI); // Each test uses a new port if the port is running on another test.
		service = new BrokerService();
        service.addConnector(uri);
        service.setPersistent(false);
		service.addConnector("stomp://localhost:61613"); // Allow stomp connections (for Python clients, etc.).
        SystemUsage systemUsage = service.getSystemUsage();
        systemUsage.getStoreUsage().setLimit(1024 * 1024 * 8);
        systemUsage.getTempUsage().setLimit(1024 * 1024 * 8);
        service.start();
		service.waitUntilStarted();
		return uri;

	} catch (Exception ne) {
		throw new EventException(ne);
	}
}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:29,代碼來源:ActivemqConnectorService.java

示例3: setUp

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Before
@Override
public void setUp() throws Exception {
    super.setUp();

    brokerService = new BrokerService();
    brokerService.setPersistent(false);
    brokerService.setUseJmx(false);
    brokerService.setAdvisorySupport(false);
    brokerService.setSchedulerSupport(false);
    TransportConnector connector = brokerService.addConnector("tcp://localhost:0");
    brokerService.start();
    connectionUri = connector.getPublishableConnectString();
    factory = new ActiveMQConnectionFactory(connectionUri);
    pooledFactory = new JmsPoolConnectionFactory();
    pooledFactory.setConnectionFactory(factory);
    pooledFactory.setMaxConnections(1);
    pooledFactory.setBlockIfSessionPoolIsFull(false);
    pooledFactory.setMaximumActiveSessionPerConnection(1);
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:21,代碼來源:PooledSessionExhaustionTest.java

示例4: setUp

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Override
@Before
public void setUp() throws Exception {
    super.setUp();

    brokerService = new BrokerService();
    brokerService.setPersistent(false);
    brokerService.setUseJmx(false);
    brokerService.setAdvisorySupport(false);
    brokerService.setSchedulerSupport(false);
    TransportConnector connector = brokerService.addConnector("tcp://localhost:0");
    brokerService.start();

    connectionUri = connector.getPublishableConnectString();
    factory = new ActiveMQConnectionFactory(connectionUri);
    pooledFactory = new JmsPoolConnectionFactory();
    pooledFactory.setConnectionFactory(factory);
    pooledFactory.setMaxConnections(1);
    pooledFactory.setBlockIfSessionPoolIsFull(false);
    pooledFactory.setUseAnonymousProducers(false);
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:22,代碼來源:PooledSessionNoPublisherCachingTest.java

示例5: setUp

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Override
@Before
public void setUp() throws Exception {
    super.setUp();

    brokerService = new BrokerService();
    brokerService.setPersistent(false);
    brokerService.setUseJmx(true);
    brokerService.getManagementContext().setCreateConnector(false);
    brokerService.setAdvisorySupport(false);
    brokerService.setSchedulerSupport(false);
    TransportConnector connector = brokerService.addConnector("tcp://localhost:0");
    brokerService.start();

    connectionUri = connector.getPublishableConnectString();
    factory = new ActiveMQConnectionFactory(connectionUri);
    pooledFactory = new JmsPoolConnectionFactory();
    pooledFactory.setConnectionFactory(factory);
    pooledFactory.setMaxConnections(1);
    pooledFactory.setBlockIfSessionPoolIsFull(false);
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:22,代碼來源:PooledSessionTest.java

示例6: setUp

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Override
@Before
public void setUp() throws Exception {
    super.setUp();

    brokerService = new BrokerService();
    brokerService.setUseJmx(false);
    brokerService.setPersistent(false);
    brokerService.setSchedulerSupport(false);
    brokerService.setAdvisorySupport(false);
    TransportConnector connector = brokerService.addConnector("tcp://localhost:0");
    brokerService.start();
    factory = new ActiveMQConnectionFactory("mock:" + connector.getConnectUri() + "?closeAsync=false");
    pooledFactory = new JmsPoolConnectionFactory();
    pooledFactory.setConnectionFactory(factory);
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:17,代碼來源:PooledConnectionFactoryWithTemporaryDestinationsTest.java

示例7: setUp

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Override
@Before
public void setUp() throws Exception {
    super.setUp();

    brokerService = new BrokerService();
    brokerService.setUseJmx(false);
    brokerService.setPersistent(false);
    brokerService.setSchedulerSupport(false);
    brokerService.setAdvisorySupport(false);
    TransportConnector connector = brokerService.addConnector("tcp://localhost:0");
    brokerService.start();
    factory = new ActiveMQConnectionFactory("mock:" + connector.getConnectUri());
    pooledFactory = new JmsPoolConnectionFactory();
    pooledFactory.setConnectionFactory(factory);
    pooledFactory.setMaxConnections(1);
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:18,代碼來源:PooledConnectionExpiryEvictsFromPoolTest.java

示例8: ServerSide

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
public ServerSide() {
    try {
        //This message broker is embedded
        BrokerService broker = new BrokerService();
        broker.setPersistent(false);
        broker.setUseJmx(false);
        broker.addConnector(messageBrokerUrl);
        broker.start();
    } catch (Exception e) {
        //Handle the exception appropriately
    }
    QueueConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
    //Delegating the handling of messages to another class, instantiate it before setting up JMS so it
    //is ready to handle messages
    this.messageProtocol = new MessageProtocol();
    this.setupMessageQueueConsumer(connectionFactory);
}
 
開發者ID:mariaklimenko,項目名稱:jeta,代碼行數:18,代碼來源:ServerSide.java

示例9: startMessagingSystem

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
private void startMessagingSystem()
{
    try
    {
        brokerService = new BrokerService();
        brokerService.addConnector(url+this.getApplicationPort2());
        brokerService.setPersistent(false);
        brokerService.setUseJmx(false);
        brokerService.setBrokerName("MithraTest"+this.getApplicationPort2());
        brokerService.setShutdownOnMasterFailure(false);
        brokerService.start();
    }
    catch(Exception e)
    {
       getLogger().error("Unable to start messaging broker");
       throw new RuntimeException("Exception during messaging broker startup", e);
    }
}
 
開發者ID:goldmansachs,項目名稱:reladomo,代碼行數:19,代碼來源:MultiVmNotificationsTestSuite.java

示例10: startService

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
public void startService() {
  if (startedFlag.get()) {
    return;
  }

  synchronized (INSTANCE) {
    if (startedFlag.get()) {
      return;
    }

    try {
      Configuration configuration = ConfigurationReader.INSTANCE
          .readConfiguration("channel-site.xml");
      String port = configuration.get("events.channel.default.port", "61616");
      broker = new BrokerService();
      broker.addConnector("tcp://localhost:" + port);
      broker.start();
      startedFlag.set(true);
    } catch (Exception e) {
      throw new IllegalStateException("Event MQ Channel Initialization Failure", e);
    }
  }
}
 
開發者ID:DataRPM-Labs,項目名稱:sigma-events,代碼行數:24,代碼來源:EmbeddedActiveMQService.java

示例11: startBroker

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
private boolean startBroker() {
    try {
        log.info("JMSServerController: Preparing to start JMS Broker: " );
        broker = new BrokerService();
        // configure the broker

        broker.setBrokerName("myBroker1");
        log.info(broker.getBrokerDataDirectory());
        broker.setDataDirectory(System.getProperty(FrameworkConstants.CARBON_HOME) +
                File.separator + broker.getBrokerDataDirectory());
        broker.setTransportConnectors(getTCPConnectors());
        broker.setPersistent(true);

        broker.start();
        log.info("JMSServerController: Broker is Successfully started. continuing tests");
        return true;
    } catch (Exception e) {
        log.error(
                "JMSServerController: There was an error starting JMS broker: ", e);
        return false;
    }
}
 
開發者ID:wso2,項目名稱:product-ei,代碼行數:23,代碼來源:JMSEndpointSuspensionViaVFSTest.java

示例12: startBroker

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Before
public void startBroker() throws Exception {
  LOG.info("Finding free network port");
  try (ServerSocket socket = new ServerSocket(0)) {
    port = socket.getLocalPort();
  }

  LOG.info("Starting ActiveMQ brokerService on {}", port);
  brokerService = new BrokerService();
  brokerService.setDeleteAllMessagesOnStartup(true);
  // use memory persistence for the test: it's faster and don't pollute test folder with KahaDB
  brokerService.setPersistent(false);
  brokerService.addConnector("mqtt://localhost:" + port);
  brokerService.start();
  brokerService.waitUntilStarted();
}
 
開發者ID:apache,項目名稱:beam,代碼行數:17,代碼來源:MqttIOTest.java

示例13: run

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
public void run() {
    try {  
        BrokerService broker = new BrokerService();
        synchronized (this) {                                     
            broker.setPersistenceAdapter(new MemoryPersistenceAdapter());                    
            broker.setTmpDataDirectory(new File("./target"));
            broker.addConnector(brokerUrl);
            broker.start();
            Thread.sleep(200);
            notifyAll();
        }
        synchronized (this) {
            while (!shutdownBroker) {
                wait(1000);
            }
        }                
        broker.stop();              
        broker = null;                
    } catch (Exception e) {
        exception = e;
        e.printStackTrace();
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:24,代碼來源:JmsBroker.java

示例14: run

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
public void run() {
    try {  
        BrokerService broker = new BrokerService();
        synchronized (this) {                                     
            broker.setPersistenceAdapter(new MemoryPersistenceAdapter());                    
            broker.setTmpDataDirectory(new File("./target"));
            broker.addConnector(brokerUrl);
            broker.start();
            Thread.sleep(200);
            notifyAll();
        }
        synchronized (this) {
            while (!shutdownBroker) {
                wait(1000);
            }
        }                
        broker.stop();              
    } catch (Exception e) {
        exception = e;
        e.printStackTrace();
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:23,代碼來源:JmsBroker.java

示例15: setUp

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {

    port = PortUtils.findOpenPortStartAt(4000);
    broker = new BrokerService();
    broker.addConnector("tcp://localhost:" + port);
    broker.start();

    final JmsServiceBuilder jmsBuilder = JmsServiceBuilder.newJmsServiceBuilder()
            .setDefaultDestination("foobarQueue").setAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE).setPort(port);

    final Queue<String> textQueue = new JmsTextQueue(jmsBuilder);

    personQueue = new JsonQueue<>(Person.class, textQueue);
    personSendQueue = personQueue.sendQueue();
    personReceiveQueue = personQueue.receiveQueue();


    personSendQueue.shouldBatch();
    personSendQueue.name();
    personSendQueue.size();
    personQueue.name();
    personQueue.size();
}
 
開發者ID:advantageous,項目名稱:qbit-extensions,代碼行數:25,代碼來源:JmsTest.java


注:本文中的org.apache.activemq.broker.BrokerService.start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。