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

The following examples show how to use org.apache.activemq.broker.BrokerService#setAdvisorySupport() . 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: NumberOfDestinationsTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected void configureBroker(BrokerService answer) throws Exception {
   File dataFileDir = new File("target/test-amq-data/perfTest/kahadb");

   KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
   kaha.setDirectory(dataFileDir);
   //answer.setUseJmx(false);

   // The setEnableJournalDiskSyncs(false) setting is a little dangerous right now, as I have not verified
   // what happens if the index is updated but a journal update is lost.
   // Index is going to be in consistent, but can it be repaired?
   //kaha.setEnableJournalDiskSyncs(false);
   // Using a bigger journal file size makes he take fewer spikes as it is not switching files as often.
   //kaha.setJournalMaxFileLength(1024*100);

   // small batch means more frequent and smaller writes
   //kaha.setIndexWriteBatchSize(100);
   // do the index write in a separate thread
   //kaha.setEnableIndexWriteAsync(true);

   answer.setPersistenceAdapter(kaha);
   answer.setAdvisorySupport(false);
   answer.setEnableStatistics(false);
   answer.addConnector(bindAddress);
   answer.setDeleteAllMessagesOnStartup(true);
}
 
Example 2
Source File: MessageGroupReconnectDistributionTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected BrokerService createBroker() throws Exception {
   BrokerService service = new BrokerService();
   service.setAdvisorySupport(false);
   service.setPersistent(false);
   service.setUseJmx(true);

   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policy = new PolicyEntry();
   policy.setUseConsumerPriority(consumerPriority);
   policy.setMessageGroupMapFactoryType("cached?cacheSize=" + (numConsumers - 1));
   policyMap.setDefaultEntry(policy);
   service.setDestinationPolicy(policyMap);

   connector = service.addConnector("tcp://localhost:0");
   return service;
}
 
Example 3
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 4
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 5
Source File: JdbcDurableSubDupTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Before
public void startBroker() throws Exception {
   exceptions.clear();
   for (int i = 0; i < MAX_MESSAGES; i++) {
      dupChecker[i] = 0;
   }
   broker = new BrokerService();
   broker.setAdvisorySupport(false);
   broker.setPersistenceAdapter(new JDBCPersistenceAdapter());
   PolicyEntry policyEntry = new PolicyEntry();
   policyEntry.setMaxAuditDepth(3000);
   policyEntry.setMaxPageSize(150);
   policyEntry.setPrioritizedMessages(true);
   PolicyMap policyMap = new PolicyMap();
   policyMap.setDefaultEntry(policyEntry);
   broker.setDestinationPolicy(policyMap);

   broker.addConnector("tcp://localhost:0");
   broker.setDeleteAllMessagesOnStartup(true);
   broker.start();
   broker.waitUntilStarted();
   url = broker.getTransportConnectors().get(0).getConnectUri().toString() + "?" + urlOptions;
}
 
Example 6
Source File: ActiveMQTestBase.java    From vertx-proton with Apache License 2.0 6 votes vote down vote up
protected BrokerService createBroker(String name, boolean deleteMessagesOnStartup,
                                     Map<String, Integer> portMap) throws Exception {
  BrokerService brokerService = new BrokerService();
  brokerService.setBrokerName(name);
  brokerService.setDeleteAllMessagesOnStartup(deleteMessagesOnStartup);
  brokerService.setUseJmx(true);
  brokerService.getManagementContext().setCreateConnector(false);
  brokerService.setDataDirectory(DATA_PARENT_DIR + File.separator + "data" + File.separator + name);
  brokerService.setPersistent(false);
  brokerService.setSchedulerSupport(false);
  brokerService.setAdvisorySupport(false);

  ArrayList<BrokerPlugin> plugins = new ArrayList<BrokerPlugin>();
  BrokerPlugin authenticationPlugin = configureAuthentication();
  if (authenticationPlugin != null) {
    plugins.add(authenticationPlugin);
  }

  if (!plugins.isEmpty()) {
    brokerService.setPlugins(plugins.toArray(new BrokerPlugin[0]));
  }

  addAdditionalConnectors(brokerService, portMap);

  return brokerService;
}
 
Example 7
Source File: PahoIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
    brokerService = new BrokerService();
    brokerService.setPersistent(false);
    brokerService.setAdvisorySupport(false);
    brokerService.addConnector(MQTT_CONNECTION);
    brokerService.start();
}
 
Example 8
Source File: QpidJmsPoolTestSupport.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
protected BrokerService createBroker() throws Exception {
    BrokerService brokerService = new BrokerService();
    brokerService.setDeleteAllMessagesOnStartup(true);
    brokerService.setPersistent(false);
    brokerService.setUseJmx(false);
    brokerService.setAdvisorySupport(false);
    brokerService.setSchedulerSupport(false);

    connectionURI = brokerService.addConnector("amqp://localhost:0").getPublishableConnectString();

    brokerService.start();
    brokerService.waitUntilStarted();

    return brokerService;
}
 
Example 9
Source File: JmsSSLConnectionTest.java    From qpid-jms with Apache License 2.0 5 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);

    // Setup broker SSL context...
    TransportOptions sslOptions = new TransportOptions();
    sslOptions.setKeyStoreLocation(KEYSTORE);
    sslOptions.setKeyStorePassword(PASSWORD);
    sslOptions.setVerifyHost(false);

    SSLContext sslContext = TransportSupport.createJdkSslContext(sslOptions);

    final SslContext brokerContext = new SslContext();
    brokerContext.setSSLContext(sslContext);

    brokerService.setSslContext(brokerContext);

    TransportConnector connector = brokerService.addConnector("amqp+ssl://localhost:0");
    brokerService.start();
    brokerService.waitUntilStarted();

    connectionURI = connector.getPublishableConnectURI();
}
 
Example 10
Source File: JmsWSSConnectionTest.java    From qpid-jms with Apache License 2.0 5 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);

    // Setup broker SSL context...
    TransportOptions sslOptions = new TransportOptions();
    sslOptions.setKeyStoreLocation(KEYSTORE);
    sslOptions.setKeyStorePassword(PASSWORD);
    sslOptions.setVerifyHost(false);

    SSLContext sslContext = TransportSupport.createJdkSslContext(sslOptions);

    final SslContext brokerContext = new SslContext();
    brokerContext.setSSLContext(sslContext);

    brokerService.setSslContext(brokerContext);

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

    brokerService.start();
    brokerService.waitUntilStarted();

    connectionURI = connector.getPublishableConnectURI();
}
 
Example 11
Source File: JmsDiscoveryProviderTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
protected BrokerService createBroker() throws Exception {

        BrokerService brokerService = new BrokerService();
        brokerService.setBrokerName("localhost");
        brokerService.setPersistent(false);
        brokerService.setAdvisorySupport(false);
        brokerService.setUseJmx(false);

        TransportConnector connector = brokerService.addConnector("amqp://0.0.0.0:0");
        connector.setName("amqp");
        connector.setDiscoveryUri(new URI("multicast://default"));

        return brokerService;
    }
 
Example 12
Source File: UnlimitedEnqueueTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Before
public void createBrokerService() throws Exception {
   brokerService = new BrokerService();
   brokerService.setDeleteAllMessagesOnStartup(true);
   brokerService.setAdvisorySupport(false);

   // optional, reduce the usage limit so that spooling will occur faster
   brokerService.getSystemUsage().getMemoryUsage().setLimit(10 * 1024 * 1024);
   brokerService.getSystemUsage().getTempUsage().setLimit((numMessages * payLoadSize) + (1000 * payLoadSize));

   PolicyMap policyMap = new PolicyMap();
   List<PolicyEntry> entries = new ArrayList<>();
   PolicyEntry policy = new PolicyEntry();

   // NB: ensure queue cursor limit is below the default 70% usage that the destination will use
   // if they are the same, the queue memory limit and flow control will kick in first
   policy.setCursorMemoryHighWaterMark(20);

   // on by default
   //policy.setProducerFlowControl(true);
   policy.setQueue(">");

   // policy that will spool references to disk
   policy.setPendingQueuePolicy(new FilePendingQueueMessageStoragePolicy());
   entries.add(policy);
   policyMap.setPolicyEntries(entries);
   brokerService.setDestinationPolicy(policyMap);

   brokerService.start();
}
 
Example 13
Source File: ConcurrentDestinationCreationTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
BrokerService createBroker() throws Exception {
   BrokerService service = new BrokerService();
   service.setDeleteAllMessagesOnStartup(true);
   service.setAdvisorySupport(false);
   service.setTransportConnectorURIs(new String[]{"tcp://localhost:0"});
   service.setPersistent(false);
   service.setUseJmx(false);
   service.start();
   return service;
}
 
Example 14
Source File: ExceptionListenerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Before
public void startBroker() throws Exception {
   brokerService = new BrokerService();
   brokerService.setAdvisorySupport(false);
   brokerService.setUseJmx(false);
   brokerService.setPersistent(false);
   brokerService.setPlugins(new BrokerPlugin[]{new SimpleAuthenticationPlugin(new ArrayList())});
   brokerUri = brokerService.addConnector("tcp://0.0.0.0:0").getConnectUri();
   brokerService.start();
}
 
Example 15
Source File: ActiveMQJmsPoolTestSupport.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
protected String createBroker() throws Exception {
    brokerService = new BrokerService();
    brokerService.setDeleteAllMessagesOnStartup(true);
    brokerService.setPersistent(false);
    brokerService.setUseJmx(true);
    brokerService.getManagementContext().setCreateConnector(false);
    brokerService.getManagementContext().setCreateMBeanServer(false);
    brokerService.setAdvisorySupport(false);
    brokerService.setSchedulerSupport(false);
    brokerService.addConnector("tcp://localhost:0").setName("test");

    ArrayList<BrokerPlugin> plugins = new ArrayList<BrokerPlugin>();

    List<AuthenticationUser> users = new ArrayList<AuthenticationUser>();
    users.add(new AuthenticationUser(USER, USER_PASSWORD, "users"));
    users.add(new AuthenticationUser(GUEST, USER_PASSWORD, "guests"));
    users.add(new AuthenticationUser(ADMIN, ADMIN, "admins"));

    SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin(users);
    authenticationPlugin.setAnonymousAccessAllowed(true);

    plugins.add(authenticationPlugin);
    plugins.add(configureAuthorization());

    brokerService.setPlugins(plugins.toArray(new BrokerPlugin[2]));

    brokerService.start();
    brokerService.waitUntilStarted();

    return brokerService.getTransportConnectorByName("test").getPublishableConnectString();
}
 
Example 16
Source File: PooledConnectionSessionCleanupTest.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.setDeleteAllMessagesOnStartup(true);
       brokerService.setPersistent(false);
       brokerService.setUseJmx(true);
       brokerService.getManagementContext().setCreateConnector(false);
       brokerService.getManagementContext().setCreateMBeanServer(false);
       brokerService.setAdvisorySupport(false);
       brokerService.setSchedulerSupport(false);
       brokerService.start();
       brokerService.waitUntilStarted();

       return brokerService.getVmConnectorURI().toString();
   }
 
Example 17
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";
}
 
Example 18
Source File: QpidJmsTestSupport.java    From qpid-jms with Apache License 2.0 4 votes vote down vote up
protected BrokerService createBroker(String name, boolean deleteAllMessages, Map<String, Integer> portMap) throws Exception {

        BrokerService brokerService = new BrokerService();
        brokerService.setBrokerName(name);
        brokerService.setPersistent(isPersistent());
        brokerService.setSchedulerSupport(isSchedulerSupport());
        brokerService.setAdvisorySupport(isAdvisorySupport());
        brokerService.setDeleteAllMessagesOnStartup(deleteAllMessages);
        brokerService.setUseJmx(true);
        brokerService.getManagementContext().setCreateConnector(false);
        brokerService.setDataDirectory("target/" + name);
        brokerService.setKeepDurableSubsActive(false);

        if (isPersistent()) {
            KahaDBStore kaha = new KahaDBStore();
            kaha.setDirectory(new File(KAHADB_DIRECTORY + "/" + name));
            kaha.setConcurrentStoreAndDispatchQueues(isConcurrentStoreAndDispatchQueues());
            kaha.setConcurrentStoreAndDispatchTopics(isConcurrentStoreAndDispatchTopics());
            kaha.setCheckpointInterval(TimeUnit.MINUTES.toMillis(5));
            brokerService.setPersistenceAdapter(kaha);
        }

        configureBrokerPolicies(brokerService);

        ArrayList<BrokerPlugin> plugins = new ArrayList<BrokerPlugin>();
        BrokerPlugin authenticationPlugin = configureAuthentication();
        if (authenticationPlugin != null) {
            plugins.add(authenticationPlugin);
        }

        BrokerPlugin authorizationPlugin = configureAuthorization();
        if (authorizationPlugin != null) {
            plugins.add(authorizationPlugin);
        }

        addAdditionalBrokerPlugins(plugins);

        if (!plugins.isEmpty()) {
            BrokerPlugin[] array = new BrokerPlugin[plugins.size()];
            brokerService.setPlugins(plugins.toArray(array));
        }

        addAdditionalConnectors(brokerService, portMap);

        return brokerService;
    }