Java Code Examples for org.apache.activemq.broker.region.policy.PolicyEntry#setPrioritizedMessages()

The following examples show how to use org.apache.activemq.broker.region.policy.PolicyEntry#setPrioritizedMessages() . 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: 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 2
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 3
Source File: DurableSubscriptionOfflineTestBase.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
protected void createBroker(boolean deleteAllMessages) throws Exception {
   String currentTestName = getName(true);
   broker = BrokerFactory.createBroker("broker:(vm://" + currentTestName + ")");
   broker.setBrokerName(currentTestName);
   broker.setDeleteAllMessagesOnStartup(deleteAllMessages);
   broker.getManagementContext().setCreateConnector(false);
   broker.setAdvisorySupport(false);
   broker.setKeepDurableSubsActive(keepDurableSubsActive);
   broker.addConnector("tcp://0.0.0.0:0");

   if (usePrioritySupport) {
      PolicyEntry policy = new PolicyEntry();
      policy.setPrioritizedMessages(true);
      PolicyMap policyMap = new PolicyMap();
      policyMap.setDefaultEntry(policy);
      broker.setDestinationPolicy(policyMap);
   }

   setDefaultPersistenceAdapter(broker);
   if (broker.getPersistenceAdapter() instanceof JDBCPersistenceAdapter) {
      // ensure it kicks in during tests
      ((JDBCPersistenceAdapter) broker.getPersistenceAdapter()).setCleanupPeriod(2 * 1000);
   } else if (broker.getPersistenceAdapter() instanceof KahaDBPersistenceAdapter) {
      // have lots of journal files
      ((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).setJournalMaxFileLength(journalMaxFileLength);
   }
   broker.start();
   broker.waitUntilStarted();
}
 
Example 4
Source File: BrokerExtension.java    From james-project with Apache License 2.0 5 votes vote down vote up
private static void enablePrioritySupport(BrokerService aBroker, String queueName) {
    PolicyMap pMap = new PolicyMap();
    PolicyEntry entry = new PolicyEntry();
    entry.setPrioritizedMessages(true);
    entry.setQueue(queueName);
    pMap.setPolicyEntries(ImmutableList.of(entry));
    aBroker.setDestinationPolicy(pMap);
}
 
Example 5
Source File: ConsumeFromAMQPTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureBrokerPolicies(BrokerService broker) {
    PolicyEntry policyEntry = new PolicyEntry();
    policyEntry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
    policyEntry.setPrioritizedMessages(false);
    policyEntry.setExpireMessagesPeriod(0);
    policyEntry.setEnableAudit(false);
    policyEntry.setOptimizedDispatch(false);
    policyEntry.setQueuePrefetch(1000);

    PolicyMap policyMap = new PolicyMap();
    policyMap.setDefaultEntry(policyEntry);
    broker.setDestinationPolicy(policyMap);
}
 
Example 6
Source File: ProducerAndConsumerBench.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureBrokerPolicies(BrokerService broker) {
    PolicyEntry policyEntry = new PolicyEntry();
    policyEntry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
    policyEntry.setPrioritizedMessages(false);
    policyEntry.setExpireMessagesPeriod(0);
    policyEntry.setEnableAudit(false);
    policyEntry.setOptimizedDispatch(true);
    policyEntry.setQueuePrefetch(1); // ensure no contention on add with
                                     // matched producer/consumer

    PolicyMap policyMap = new PolicyMap();
    policyMap.setDefaultEntry(policyEntry);
    broker.setDestinationPolicy(policyMap);
}
 
Example 7
Source File: ProduceToAMQPTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureBrokerPolicies(BrokerService broker) {
    PolicyEntry policyEntry = new PolicyEntry();
    policyEntry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
    policyEntry.setPrioritizedMessages(false);
    policyEntry.setExpireMessagesPeriod(0);
    policyEntry.setEnableAudit(false);
    policyEntry.setOptimizedDispatch(true);
    policyEntry.setQueuePrefetch(100);

    PolicyMap policyMap = new PolicyMap();
    policyMap.setDefaultEntry(policyEntry);
    broker.setDestinationPolicy(policyMap);
}
 
Example 8
Source File: XARecoveryBrokerTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
protected PolicyEntry getDefaultPolicy() {
   PolicyEntry policyEntry = super.getDefaultPolicy();
   policyEntry.setPrioritizedMessages(prioritySupport);
   return policyEntry;
}
 
Example 9
Source File: ConcurrentProducerDurableConsumerTest.java    From activemq-artemis with Apache License 2.0 4 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);

   StorePendingDurableSubscriberMessageStoragePolicy durableSubPending = new StorePendingDurableSubscriberMessageStoragePolicy();
   durableSubPending.setImmediatePriorityDispatch(true);
   durableSubPending.setUseCache(true);
   policy.setPendingDurableSubscriberPolicy(durableSubPending);

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

   //        if (false) {
   //            // external mysql works a lot faster
   //            //
   //            JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
   //            BasicDataSource ds = new BasicDataSource();
   //            com.mysql.jdbc.Driver d = new com.mysql.jdbc.Driver();
   //            ds.setDriverClassName("com.mysql.jdbc.Driver");
   //            ds.setUrl("jdbc:mysql://localhost/activemq?relaxAutoCommit=true");
   //            ds.setMaxActive(200);
   //            ds.setUsername("root");
   //            ds.setPassword("");
   //            ds.setPoolPreparedStatements(true);
   //            jdbc.setDataSource(ds);
   //            brokerService.setPersistenceAdapter(jdbc);

         /* add mysql bits to the pom in the testing dependencies
                 <dependency>
                     <groupId>mysql</groupId>
                     <artifactId>mysql-connector-java</artifactId>
                     <version>5.1.10</version>
                     <scope>test</scope>
                 </dependency>
                 <dependency>
                     <groupId>commons-dbcp</groupId>
                     <artifactId>commons-dbcp</artifactId>
                     <version>1.2.2</version>
                     <scope>test</scope>
                 </dependency>
          */
   //        } else {
   setPersistenceAdapter(brokerService, persistenceAdapterChoice);
   //        }
   return brokerService;
}