Java Code Examples for org.apache.activemq.broker.BrokerService#waitUntilStarted()

The following examples show how to use org.apache.activemq.broker.BrokerService#waitUntilStarted() . 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: NIOSSLLoadTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
   System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE);
   System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD);
   System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE);
   System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE);
   System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE);
   System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD);

   broker = new BrokerService();
   broker.setPersistent(false);
   broker.setUseJmx(false);
   TransportConnector connector = broker.addConnector("nio+ssl://localhost:0?transport.needClientAuth=true&transport.enabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA");
   broker.start();
   broker.waitUntilStarted();

   ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("nio+ssl://localhost:" + connector.getConnectUri().getPort());
   connection = factory.createConnection();
   session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   connection.start();
}
 
Example 2
Source File: BrokerNetworkWithStuckMessagesTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected BrokerService createSecondRemoteBroker() throws Exception {
   secondRemoteBroker = new BrokerService();
   secondRemoteBroker.setBrokerName("secondRemotehost");
   secondRemoteBroker.setUseJmx(false);
   secondRemoteBroker.setPersistenceAdapter(null);
   secondRemoteBroker.setPersistent(false);
   secondRemoteConnector = createSecondRemoteConnector();
   secondRemoteBroker.addConnector(secondRemoteConnector);
   configureBroker(secondRemoteBroker);
   secondRemoteBroker.start();
   secondRemoteBroker.waitUntilStarted();

   brokers.put(secondRemoteBroker.getBrokerName(), secondRemoteBroker);

   return secondRemoteBroker;
}
 
Example 3
Source File: ExpiredMessagesTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private BrokerService createBroker(boolean deleteAllMessages, long expireMessagesPeriod) throws Exception {
   BrokerService broker = new BrokerService();
   broker.setBrokerName("localhost");
   broker.setDestinations(new ActiveMQDestination[]{destination});
   broker.setPersistenceAdapter(new MemoryPersistenceAdapter());

   PolicyEntry defaultPolicy = new PolicyEntry();
   if (useVMCursor) {
      defaultPolicy.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
   }
   defaultPolicy.setExpireMessagesPeriod(expireMessagesPeriod);
   defaultPolicy.setMaxExpirePageSize(1200);
   PolicyMap policyMap = new PolicyMap();
   policyMap.setDefaultEntry(defaultPolicy);
   broker.setDestinationPolicy(policyMap);
   broker.setDeleteAllMessagesOnStartup(deleteAllMessages);
   broker.addConnector("tcp://localhost:0");
   broker.start();
   broker.waitUntilStarted();
   return broker;
}
 
Example 4
Source File: JmsWSConnectionTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    brokerService = new BrokerService();
    brokerService.setPersistent(false);
    brokerService.setAdvisorySupport(false);
    brokerService.setDeleteAllMessagesOnStartup(true);
    brokerService.setUseJmx(false);

    TransportConnector connector = brokerService.addConnector(
            "ws://0.0.0.0:" + getProxyPort() + "?websocket.maxBinaryMessageSize=1048576");
    connectionURI = connector.getPublishableConnectURI();
    LOG.debug("Using amqp+ws connection: {}", connectionURI);

    brokerService.start();
    brokerService.waitUntilStarted();
}
 
Example 5
Source File: TopicSubscriptionSlowConsumerTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private BrokerService createBroker() throws Exception {
   BrokerService broker = new BrokerService();
   broker.setBrokerName("localhost");
   broker.setUseJmx(true);
   broker.setDeleteAllMessagesOnStartup(true);
   broker.addConnector("vm://localhost");

   PolicyMap policyMap = new PolicyMap();
   PolicyEntry defaultEntry = new PolicyEntry();
   defaultEntry.setAdvisoryForSlowConsumers(true);

   policyMap.setDefaultEntry(defaultEntry);

   broker.setDestinationPolicy(policyMap);
   broker.start();
   broker.waitUntilStarted();
   return broker;
}
 
Example 6
Source File: ActiveMQXAConnectionFactoryTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
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 7
Source File: NIOSSLConcurrencyTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
   System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE);
   System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD);
   System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE);
   System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE);
   System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE);
   System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD);

   broker = new BrokerService();
   broker.setPersistent(false);
   broker.setUseJmx(false);
   TransportConnector connector = broker.addConnector("nio+ssl://localhost:0?transport.needClientAuth=true&transport.enabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA");
   broker.start();
   broker.waitUntilStarted();

   failed = false;
   messageData = new byte[MESSAGE_SIZE];
   for (int i = 0; i < MESSAGE_SIZE; i++) {
      messageData[i] = (byte) (i & 0xff);
   }

   ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("nio+ssl://localhost:" + connector.getConnectUri().getPort());
   connection = factory.createConnection();

   for (int i = 0; i < PRODUCER_COUNT; i++) {
      producerSessions[i] = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   }

   for (int i = 0; i < CONSUMER_COUNT; i++) {
      consumerSessions[i] = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   }

   connection.start();
}
 
Example 8
Source File: NetworkLoopBackTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testLoopbackOnDifferentUrlScheme() throws Exception {
   final BrokerService brokerServce = new BrokerService();
   brokerServce.setPersistent(false);

   TransportConnector transportConnector = brokerServce.addConnector("nio://0.0.0.0:0");
   // connection filter is bypassed when scheme is different
   final NetworkConnector networkConnector = brokerServce.addNetworkConnector("static:(tcp://" + transportConnector.getConnectUri().getHost() + ":" + transportConnector.getConnectUri().getPort() + ")");

   brokerServce.start();
   brokerServce.waitUntilStarted();

   try {
      Wait.waitFor(new Wait.Condition() {
         @Override
         public boolean isSatisified() throws Exception {
            return 1 == networkConnector.bridges.size();
         }
      });

      final DemandForwardingBridgeSupport loopbackBridge = (DemandForwardingBridgeSupport) networkConnector.bridges.values().iterator().next();
      assertTrue("nc started", networkConnector.isStarted());

      assertTrue("It should get disposed", Wait.waitFor(new Wait.Condition() {
         @Override
         public boolean isSatisified() throws Exception {
            return loopbackBridge.getRemoteBroker().isDisposed();
         }
      }));

      assertEquals("No peer brokers", 0, brokerServce.getBroker().getPeerBrokerInfos().length);

   } finally {
      brokerServce.stop();
   }
}
 
Example 9
Source File: ProxyFailoverTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
protected void startRemoteBroker(boolean delete) throws Exception {
   remoteBroker = new BrokerService();
   remoteBroker.addConnector("tcp://localhost:61616");
   if (delete) {
      remoteBroker.deleteAllMessages();
   }
   remoteBroker.setUseJmx(false);
   remoteBroker.start();
   remoteBroker.waitUntilStarted();
}
 
Example 10
Source File: AdvisoryDuplexNetworkBridgeTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public void createBroker1() throws Exception {
   broker1 = new BrokerService();
   broker1.setBrokerName("broker1");
   broker1.addConnector("tcp://localhost:61617");
   broker1.setUseJmx(false);
   broker1.setPersistent(false);
   broker1.start();
   broker1.waitUntilStarted();
}
 
Example 11
Source File: ActiveMQXAConnectionFactoryTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
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 12
Source File: DurableSubscriptionTestSupport.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void createBroker() throws Exception {
   broker = new BrokerService();
   broker.setBrokerName("durable-broker");
   broker.setDeleteAllMessagesOnStartup(true);
   broker.setPersistenceAdapter(createPersistenceAdapter());
   broker.setPersistent(true);
   broker.start();
   broker.waitUntilStarted();

   connection = createConnection();
}
 
Example 13
Source File: ObjectMessageNotSerializableTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private BrokerService createBroker() throws Exception {
   BrokerService broker = new BrokerService();
   broker.setPersistent(false);
   broker.setUseJmx(false);
   broker.addConnector("tcp://localhost:0");

   broker.start();
   broker.waitUntilStarted();
   return broker;
}
 
Example 14
Source File: NIOSSLWindowSizeTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
   System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE);
   System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD);
   System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE);
   System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE);
   System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE);
   System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD);

   broker = new BrokerService();
   broker.setPersistent(false);
   broker.setUseJmx(false);
   TransportConnector connector = broker.addConnector("nio+ssl://localhost:0?transport.needClientAuth=true");
   broker.start();
   broker.waitUntilStarted();

   messageData = new byte[MESSAGE_SIZE];
   for (int i = 0; i < MESSAGE_SIZE; i++) {
      messageData[i] = (byte) (i & 0xff);
   }

   ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("nio+ssl://localhost:" + connector.getConnectUri().getPort());
   connection = factory.createConnection();
   session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   connection.start();
}
 
Example 15
Source File: PooledConnectionExampleTest.java    From amqp-10-jms-spring-boot with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUp() throws Exception {
    brokerService = new BrokerService();

    brokerService.addConnector("amqp://localhost:5672");
    brokerService.setPersistent(false);
    brokerService.getManagementContext().setCreateConnector(false);

    brokerService.start();
    brokerService.waitUntilStarted();
}
 
Example 16
Source File: DurableSubscriptionTestSupport.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void createRestartedBroker() throws Exception {
   broker = new BrokerService();
   broker.setBrokerName("durable-broker");
   broker.setDeleteAllMessagesOnStartup(false);
   broker.setPersistenceAdapter(createPersistenceAdapter());
   broker.setPersistent(true);
   broker.start();
   broker.waitUntilStarted();

   connection = createConnection();
}
 
Example 17
Source File: HelloWorldExampleTest.java    From amqp-10-jms-spring-boot with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUp() throws Exception {
    brokerService = new BrokerService();

    brokerService.addConnector("amqp://localhost:5672");
    brokerService.setPersistent(false);
    brokerService.getManagementContext().setCreateConnector(false);

    brokerService.start();
    brokerService.waitUntilStarted();
}
 
Example 18
Source File: JmsMultipleBrokersTestSupport.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
protected void startAllBrokers() throws Exception {
   Collection<BrokerItem> brokerList = brokers.values();
   for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
      BrokerService broker = i.next().broker;
      broker.start();
      broker.waitUntilStarted();
   }

   Thread.sleep(maxSetupTime);
}
 
Example 19
Source File: DispatchMultipleConsumersTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
   super.setUp();
   broker = new BrokerService();
   broker.setPersistent(true);
   broker.setUseJmx(true);
   broker.deleteAllMessages();
   broker.addConnector("tcp://localhost:0");
   broker.start();
   broker.waitUntilStarted();
   dest = new ActiveMQQueue(destinationName);
   resetCounters();
   brokerURL = broker.getTransportConnectors().get(0).getPublishableConnectString();
}
 
Example 20
Source File: PooledConnectionFailoverTest.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected String createBroker() throws Exception {
    brokerService = new BrokerService();
    brokerService.setBrokerName("PooledConnectionSessionCleanupTestBroker");
    brokerService.setUseJmx(true);
    brokerService.getManagementContext().setCreateConnector(false);
    brokerService.setPersistent(false);
    brokerService.setSchedulerSupport(false);
    brokerService.setAdvisorySupport(false);
    TransportConnector connector = brokerService.addConnector("tcp://0.0.0.0:61626");
    brokerService.start();
    brokerService.waitUntilStarted();

    return "failover:(" + connector.getPublishableConnectString() + ")?maxReconnectAttempts=5";
}