org.apache.activemq.broker.BrokerService Java Examples

The following examples show how to use org.apache.activemq.broker.BrokerService. 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: QueueResendDuringShutdownTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
   this.receiveCount = 0;

   this.broker = new BrokerService();
   this.broker.setPersistent(false);
   this.broker.start();
   this.broker.waitUntilStarted();

   this.factory = new ActiveMQConnectionFactory(broker.getVmConnectorURI());
   this.queue = new ActiveMQQueue("TESTQUEUE");

   connections = new Connection[NUM_CONNECTION_TO_TEST];
   int iter = 0;
   while (iter < NUM_CONNECTION_TO_TEST) {
      this.connections[iter] = factory.createConnection();
      iter++;
   }

   this.producerConnection = factory.createConnection();
   this.producerConnection.start();
}
 
Example #2
Source File: RequestReplyToTopicViaThreeNetworkHopsTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public EmbeddedTcpBroker(String name, int number) throws Exception {
   brokerSvc = new BrokerService();

   synchronized (this.getClass()) {
      brokerNum = Next_broker_num;
      Next_broker_num++;
   }

   brokerName = name + number;
   brokerId = brokerName;

   brokerSvc.setBrokerName(brokerName);
   brokerSvc.setBrokerId(brokerId);

   brokerSvc.setPersistent(false);
   brokerSvc.setUseJmx(false);

   port = 60000 + (brokerNum * 10);

   tcpUrl = "tcp://127.0.0.1:" + Integer.toString(port);
   fullUrl = tcpUrl + "?jms.watchTopicAdvisories=false";

   brokerSvc.addConnector(tcpUrl);
}
 
Example #3
Source File: AuthenticationHandler.java    From blackduck-alert with Apache License 2.0 6 votes vote down vote up
private void configureActiveMQProvider() {
    // Active MQ initializes the Bouncy Castle provider in a static constructor of the Broker Service
    // static initialization of the Bouncy Castle provider breaks SAML support over SSL
    // https://stackoverflow.com/questions/53906154/spring-boot-2-1-embedded-tomcat-keystore-password-was-incorrect
    try {
        ClassLoader loader = BrokerService.class.getClassLoader();
        Class<?> clazz = loader.loadClass("org.bouncycastle.jce.provider.BouncyCastleProvider");
        Provider bouncycastle = (Provider) clazz.getDeclaredConstructor().newInstance();
        Security.removeProvider(bouncycastle.getName());
        logger.info("Alert Application Configuration: Removing Bouncy Castle provider");
        Security.addProvider(bouncycastle);
        logger.info("Alert Application Configuration: Adding Bouncy Castle provider to the end of the provider list");

    } catch (Exception e) {
        // nothing needed here if that provider does not exist
        logger.info("Alert Application Configuration: Bouncy Castle provider not found");
    }
}
 
Example #4
Source File: SimpleNetworkTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private void waitForConsumerRegistration(final BrokerService brokerService,
                                         final int min,
                                         final ActiveMQDestination destination) throws Exception {
   assertTrue("Internal bridge consumers registered in time", Wait.waitFor(new Wait.Condition() {
      @Override
      public boolean isSatisified() throws Exception {
         Object[] bridges = brokerService.getNetworkConnectors().get(0).bridges.values().toArray();
         if (bridges.length > 0) {
            LOG.info(brokerService + " bridges " + Arrays.toString(bridges));
            DemandForwardingBridgeSupport demandForwardingBridgeSupport = (DemandForwardingBridgeSupport) bridges[0];
            ConcurrentMap<ConsumerId, DemandSubscription> forwardingBridges = demandForwardingBridgeSupport.getLocalSubscriptionMap();
            LOG.info(brokerService + " bridge " + demandForwardingBridgeSupport + ", localSubs: " + forwardingBridges);
            if (!forwardingBridges.isEmpty()) {
               for (DemandSubscription demandSubscription : forwardingBridges.values()) {
                  if (demandSubscription.getLocalInfo().getDestination().equals(destination)) {
                     LOG.info(brokerService + " DemandSubscription " + demandSubscription + ", size: " + demandSubscription.size());
                     return demandSubscription.size() >= min;
                  }
               }
            }
         }
         return false;
      }
   }));
}
 
Example #5
Source File: ActiveMQConnectionFactoryTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected void assertCreateConnection(String uri) throws Exception {
   // Start up a broker with a tcp connector.
   broker = new BrokerService();
   broker.setPersistent(false);
   broker.setUseJmx(false);
   TransportConnector connector = broker.addConnector(uri);
   broker.start();

   URI temp = new URI(uri);
   // URI connectURI = connector.getServer().getConnectURI();
   // TODO this sometimes fails when using the actual local host name
   URI currentURI = new URI(connector.getPublishableConnectString());

   // sometimes the actual host name doesn't work in this test case
   // e.g. on OS X so lets use the original details but just use the actual
   // port
   URI connectURI = new URI(temp.getScheme(), temp.getUserInfo(), temp.getHost(), currentURI.getPort(), temp.getPath(), temp.getQuery(), temp.getFragment());

   LOG.info("connection URI is: " + connectURI);

   // This should create the connection.
   ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(connectURI);
   connection = (ActiveMQConnection) cf.createConnection();
   assertNotNull(connection);
}
 
Example #6
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 #7
Source File: MemoryLimitTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected BrokerService createBroker() throws Exception {
   BrokerService broker = new BrokerService();
   broker.getSystemUsage().getMemoryUsage().setLimit(1 * 1024 * 1024); //1MB
   broker.deleteAllMessages();

   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policyEntry = new PolicyEntry();
   policyEntry.setProducerFlowControl(false);
   policyMap.put(new ActiveMQQueue(">"), policyEntry);
   broker.setDestinationPolicy(policyMap);

   LOG.info("Starting broker with persistenceAdapterChoice " + persistenceAdapterChoice.toString());
   setPersistenceAdapter(broker, persistenceAdapterChoice);
   broker.getPersistenceAdapter().deleteAllMessages();

   return broker;
}
 
Example #8
Source File: EmbeddedActiveMQBroker.java    From camel-cookbook-examples with Apache License 2.0 6 votes vote down vote up
public EmbeddedActiveMQBroker(String brokerId) {
    Validate.notEmpty(brokerId, "brokerId is empty");
    this.brokerId = brokerId;
    tcpConnectorUri = "tcp://localhost:" + AvailablePortFinder.getNextAvailable();

    brokerService = new BrokerService();
    brokerService.setBrokerId(brokerId);
    brokerService.setPersistent(false);
    brokerService.setUseJmx(false);
    try {
        brokerService.setPersistenceAdapter(new MemoryPersistenceAdapter());
        brokerService.addConnector(tcpConnectorUri);
    } catch (Exception e) {
        throw new RuntimeException("Problem creating brokerService", e);
    }
}
 
Example #9
Source File: MultiClientVmTestSuite.java    From reladomo with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #10
Source File: JmsMultipleBrokersTestSupport.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected void bridgeAllBrokers(String groupName,
                                int ttl,
                                boolean suppressduplicateQueueSubs,
                                boolean decreasePriority) throws Exception {
   Collection<BrokerItem> brokerList = brokers.values();
   for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
      BrokerService broker = i.next().broker;
      List<TransportConnector> transportConnectors = broker.getTransportConnectors();

      if (transportConnectors.isEmpty()) {
         broker.addConnector(new URI(AUTO_ASSIGN_TRANSPORT));
         transportConnectors = broker.getTransportConnectors();
      }

      TransportConnector transport = transportConnectors.get(0);
      transport.setDiscoveryUri(new URI("multicast://default?group=" + groupName));
      NetworkConnector nc = broker.addNetworkConnector("multicast://default?group=" + groupName);
      nc.setNetworkTTL(ttl);
      nc.setSuppressDuplicateQueueSubscriptions(suppressduplicateQueueSubs);
      nc.setDecreaseNetworkConsumerPriority(decreasePriority);
   }

   // Multicasting may take longer to setup
   maxSetupTime = 8000;
}
 
Example #11
Source File: MQTTStreamSourceTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void startBroker() throws Exception {
  port = findFreePort();
  brokerService = new BrokerService();
  brokerService.setDeleteAllMessagesOnStartup( true );
  brokerService.setPersistent( false );
  brokerService.addConnector( "mqtt://localhost:" + port );
  brokerService.start();
  brokerService.waitUntilStarted();
  when( consumerMeta.getQos() ).thenReturn( "2" );
  when( consumerMeta.withVariables( any() ) ).thenReturn( consumerMeta );
  when( consumerMeta.getMqttServer() ).thenReturn( "127.0.0.1:" + port );
  when( consumerMeta.getTopics() ).thenReturn( singletonList( "mytopic" ) );
  when( mqttConsumer.environmentSubstitute( anyString() ) )
    .thenAnswer( answer -> answer.getArguments()[ 0 ] );
  when( mqttConsumer.environmentSubstitute( any( String[].class ) ) )
    .thenAnswer( answer -> answer.getArguments()[ 0 ] );
  when( mqttConsumer.getLogChannel() ).thenReturn( logger );
  when( mqttConsumer.getStepMeta() ).thenReturn( stepMeta );
  when( stepMeta.getName() ).thenReturn( "Mqtt Step" );
  when( mqttConsumer.getVariablizedStepMeta() ).thenReturn( consumerMeta );
  when( subtransExecutor.getPrefetchCount() ).thenReturn( 1000 );
  when( mqttConsumer.getSubtransExecutor() ).thenReturn( subtransExecutor );
}
 
Example #12
Source File: QueuePurgeTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
   setMaxTestTime(10 * 60 * 1000); // 10 mins
   setAutoFail(true);
   super.setUp();
   broker = new BrokerService();

   File testDataDir = new File("target/activemq-data/QueuePurgeTest");
   broker.setDataDirectoryFile(testDataDir);
   broker.setUseJmx(true);
   broker.setDeleteAllMessagesOnStartup(true);
   broker.getSystemUsage().getMemoryUsage().setLimit(1024L * 1024 * 64);
   KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter();
   persistenceAdapter.setDirectory(new File(testDataDir, "kahadb"));
   broker.setPersistenceAdapter(persistenceAdapter);
   broker.addConnector("tcp://localhost:0");
   broker.start();
   factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri().toString());
   connection = factory.createConnection();
   connection.start();
}
 
Example #13
Source File: IgniteJmsStreamerTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@SuppressWarnings("unchecked")
@Override public void beforeTest() throws Exception {
    grid().<Integer, String>getOrCreateCache(defaultCacheConfiguration());

    broker = new BrokerService();
    broker.setDeleteAllMessagesOnStartup(true);
    broker.setPersistent(false);
    broker.setPersistenceAdapter(null);
    broker.setPersistenceFactory(null);

    PolicyMap plcMap = new PolicyMap();
    PolicyEntry plc = new PolicyEntry();

    plc.setQueuePrefetch(1);

    broker.setDestinationPolicy(plcMap);
    broker.getDestinationPolicy().setDefaultEntry(plc);
    broker.setSchedulerSupport(false);

    broker.start(true);

    connFactory = new ActiveMQConnectionFactory(BrokerRegistry.getInstance().findFirst().getVmConnectorURI());
}
 
Example #14
Source File: ActiveMQResourceAdapter.java    From tomee with Apache License 2.0 6 votes vote down vote up
private void stopImpl() throws Exception {
    super.stop();
    final Collection<BrokerService> brokers = ActiveMQFactory.getBrokers();
    final Iterator<BrokerService> it = brokers.iterator();
    while (it.hasNext()) {
        final BrokerService bs = it.next();
        try {
            bs.stop();
            bs.waitUntilStopped();
        } catch (final Throwable t) {
            //Ignore
        }
        it.remove();
    }
    stopScheduler();
    Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQResourceAdapter.class).getChildLogger("service").info("Stopped ActiveMQ broker");
}
 
Example #15
Source File: ConcurrentProducerQueueConsumerTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected BrokerService createBroker() throws Exception {
   BrokerService brokerService = new BrokerService();
   brokerService.setEnableStatistics(false);
   brokerService.addConnector("tcp://0.0.0.0:0");
   brokerService.setDeleteAllMessagesOnStartup(true);

   PolicyEntry policy = new PolicyEntry();
   policy.setPrioritizedMessages(true);
   policy.setMaxPageSize(500);

   PolicyMap policyMap = new PolicyMap();
   policyMap.setDefaultEntry(policy);
   brokerService.setDestinationPolicy(policyMap);
   setDefaultPersistenceAdapter(brokerService);

   return brokerService;
}
 
Example #16
Source File: RequestReplyNoAdvisoryNetworkTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private BrokerService configureBroker(String brokerName) throws Exception {
   BrokerService broker = new BrokerService();
   broker.setBrokerName(brokerName);
   broker.setAdvisorySupport(false);
   broker.setPersistent(false);
   broker.setUseJmx(false);
   broker.setSchedulePeriodForDestinationPurge(1000);
   broker.setAllowTempAutoCreationOnSend(true);

   PolicyMap map = new PolicyMap();
   PolicyEntry tempReplyQPolicy = new PolicyEntry();
   tempReplyQPolicy.setOptimizedDispatch(true);
   tempReplyQPolicy.setGcInactiveDestinations(true);
   tempReplyQPolicy.setGcWithNetworkConsumers(true);
   tempReplyQPolicy.setInactiveTimeoutBeforeGC(1000);
   map.put(replyQWildcard, tempReplyQPolicy);
   broker.setDestinationPolicy(map);

   broker.addConnector("tcp://localhost:0");
   brokers.add(broker);
   return broker;
}
 
Example #17
Source File: JMXRemoveQueueThenSendIgnoredTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
   brokerService = new BrokerService();
   brokerService.setBrokerName("dev");
   brokerService.setPersistent(false);
   brokerService.setUseJmx(true);
   brokerService.addConnector("tcp://localhost:0");
   brokerService.start();

   final String brokerUri = brokerService.getTransportConnectors().get(0).getPublishableConnectString();

   ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(brokerUri);
   connection = activeMQConnectionFactory.createQueueConnection();
   session = connection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE/*SESSION_TRANSACTED*/);
   queue = session.createQueue("myqueue");
   producer = session.createProducer(queue);
   producer.setDeliveryMode(DeliveryMode.PERSISTENT);

   connection.start();
}
 
Example #18
Source File: EmbeddedBrokerTestSupport.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
   BrokerService.disableWrapper = disableWrapper;
   File tmpRoot = new File("./target/tmp");
   tmpRoot.mkdirs();
   temporaryFolder = new TemporaryFolder(tmpRoot);
   temporaryFolder.create();

   if (artemisBroker == null) {
      artemisBroker = createArtemisBroker();
   }
   startBroker();

   connectionFactory = createConnectionFactory();

   destination = createDestination();

   template = createJmsTemplate();
   template.setDefaultDestination(destination);
   template.setPubSubDomain(useTopic);
   template.afterPropertiesSet();
}
 
Example #19
Source File: NonBlockingConsumerRedeliveryTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Before
public void startBroker() throws Exception {
   broker = new BrokerService();
   broker.setDeleteAllMessagesOnStartup(true);
   broker.setPersistent(false);
   broker.setUseJmx(false);
   broker.addConnector("tcp://0.0.0.0:0");
   broker.start();
   broker.waitUntilStarted();

   connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
   connectionFactory = new ActiveMQConnectionFactory(connectionUri);
   connectionFactory.setNonBlockingRedelivery(true);

   RedeliveryPolicy policy = connectionFactory.getRedeliveryPolicy();
   policy.setInitialRedeliveryDelay(TimeUnit.SECONDS.toMillis(2));
   policy.setBackOffMultiplier(-1);
   policy.setRedeliveryDelay(TimeUnit.SECONDS.toMillis(2));
   policy.setMaximumRedeliveryDelay(-1);
   policy.setUseExponentialBackOff(false);
   policy.setMaximumRedeliveries(-1);
}
 
Example #20
Source File: AbortSlowConsumerBase.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();
   PolicyEntry policy = new PolicyEntry();
   underTest.setAbortConnection(abortConnection);
   underTest.setCheckPeriod(checkPeriod);
   underTest.setMaxSlowDuration(maxSlowDuration);

   policy.setSlowConsumerStrategy(underTest);
   policy.setQueuePrefetch(10);
   policy.setTopicPrefetch(10);
   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);
   broker.setDestinationPolicy(pMap);
   return broker;
}
 
Example #21
Source File: DiscriminatingConsumerLoadTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
   broker = new BrokerService();
   broker.setPersistent(false);

   // workaround is to ensure sufficient dispatch buffer for the destination
   PolicyMap policyMap = new PolicyMap();
   PolicyEntry defaultPolicy = new PolicyEntry();
   defaultPolicy.setMaxPageSize(testSize);
   policyMap.setDefaultEntry(defaultPolicy);
   broker.setDestinationPolicy(policyMap);
   broker.start();

   super.setUp();
   this.producerConnection = this.createConnection();
   this.consumerConnection = this.createConnection();
}
 
Example #22
Source File: RemoveDestinationTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
   BrokerService.disableWrapper = true;
   broker = BrokerFactory.createBroker(new URI(BROKER_URL));
   broker.start();
   broker.waitUntilStarted();
}
 
Example #23
Source File: SchedulerDBVersionTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
protected BrokerService createBroker(JobSchedulerStoreImpl scheduler) throws Exception {
   BrokerService answer = new BrokerService();
   answer.setJobSchedulerStore(scheduler);
   answer.setPersistent(true);
   answer.setDataDirectory("target");
   answer.setSchedulerSupport(true);
   answer.setUseJmx(false);
   return answer;
}
 
Example #24
Source File: ActiveMQ5FactoryTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Test
public void setPlugins() throws Exception {
    final URI brokerURI = new URI("amq5factory:broker:(tcp://localhost:" + getNextAvailablePort() + ")?" +
            "amq.plugins=jaas&" +
            "jaas.class=" + JaasAuthenticationPlugin.class.getName() + "&" +
            "jaas.discoverLoginConfig=false");
    final BrokerService bs = new ActiveMQ5Factory().createBroker(brokerURI);
    bs.stop();
    ActiveMQ5Factory.brokers.remove(brokerURI);
    assertNotNull(bs.getPlugins());
    assertEquals(1, bs.getPlugins().length);
    assertTrue(JaasAuthenticationPlugin.class.isInstance(bs.getPlugins()[0]));
    assertFalse(JaasAuthenticationPlugin.class.cast(bs.getPlugins()[0]).isDiscoverLoginConfig()); // default is true
}
 
Example #25
Source File: JDBCQueueMasterSlaveTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected void createSlave() throws Exception {
   // use a separate thread as the slave will block waiting for
   // the exclusive db lock
   Thread t = new Thread() {
      @Override
      public void run() {
         try {
            BrokerService broker = new BrokerService();
            broker.setBrokerName("slave");
            TransportConnector connector = new TransportConnector();
            connector.setUri(new URI(SLAVE_URL));
            broker.addConnector(connector);
            // no need for broker.setMasterConnectorURI(masterConnectorURI)
            // as the db lock provides the slave/master initialisation
            broker.setUseJmx(false);
            broker.setPersistent(true);
            JDBCPersistenceAdapter persistenceAdapter = new JDBCPersistenceAdapter();
            persistenceAdapter.setDataSource(getExistingDataSource());
            persistenceAdapter.setCreateTablesOnStartup(false);
            broker.setPersistenceAdapter(persistenceAdapter);
            configureJdbcPersistenceAdapter(persistenceAdapter);
            configureBroker(broker);
            broker.start();
            slave.set(broker);
            slaveStarted.countDown();
         } catch (IllegalStateException expectedOnShutdown) {
         } catch (Exception e) {
            fail("failed to start slave broker, reason:" + e);
         }
      }
   };
   t.start();
}
 
Example #26
Source File: JmsMultipleBrokersTestSupport.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public BrokerItem(BrokerService broker) throws Exception {
   this.broker = broker;

   factory = new ActiveMQConnectionFactory(broker.getVmConnectorURI());
   factory.setConnectionIDPrefix(broker.getBrokerName());
   consumers = Collections.synchronizedMap(new HashMap<MessageConsumer, MessageIdList>());
   connections = Collections.synchronizedList(new ArrayList<Connection>());
   allMessages.setVerbose(verbose);
   id = new IdGenerator(broker.getBrokerName() + ":");
}
 
Example #27
Source File: SslContextNBrokerServiceTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
   // System.setProperty("javax.net.debug", "ssl");
   Thread.currentThread().setContextClassLoader(SslContextNBrokerServiceTest.class.getClassLoader());
   context = new ClassPathXmlApplicationContext("org/apache/activemq/transport/tcp/n-brokers-ssl.xml");
   beansOfType = context.getBeansOfType(BrokerService.class);
}
 
Example #28
Source File: BrokerPropertiesTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public void testVmBrokerPropertiesFile() throws Exception {
   ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost?brokerConfig=properties:org/apache/activemq/config/broker.properties");
   Connection connection = factory.createConnection();
   BrokerService broker = BrokerRegistry.getInstance().lookup("Cheese");
   LOG.info("Found broker : " + broker);
   assertNotNull(broker);

   assertEquals("isUseJmx()", false, broker.isUseJmx());
   assertEquals("isPersistent()", false, broker.isPersistent());
   assertEquals("getBrokerName()", "Cheese", broker.getBrokerName());
   connection.close();
   broker.stop();
}
 
Example #29
Source File: KahaDBSchedulerIndexRebuildTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
protected BrokerService createBroker(JobSchedulerStoreImpl scheduler) throws Exception {
   BrokerService answer = new BrokerService();
   answer.setJobSchedulerStore(scheduler);
   answer.setPersistent(true);
   answer.setDataDirectory(storeDir.getAbsolutePath());
   answer.setSchedulerSupport(true);
   answer.setUseJmx(false);
   return answer;
}
 
Example #30
Source File: SslContextNBrokerServiceTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private boolean verifyCredentials(String name) throws Exception {
   boolean result = false;
   BrokerService broker = getBroker(name);
   assertNotNull(name, broker);
   broker.start();
   broker.waitUntilStarted();
   try {
      result = verifySslCredentials(broker);
   } finally {
      broker.stop();
   }
   return result;
}