当前位置: 首页>>代码示例>>Java>>正文


Java PolicyMap.put方法代码示例

本文整理汇总了Java中org.apache.activemq.broker.region.policy.PolicyMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java PolicyMap.put方法的具体用法?Java PolicyMap.put怎么用?Java PolicyMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.activemq.broker.region.policy.PolicyMap的用法示例。


在下文中一共展示了PolicyMap.put方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureBroker

import org.apache.activemq.broker.region.policy.PolicyMap; //导入方法依赖的package包/类
@Override
protected void configureBroker(BrokerService broker) throws Exception {
    broker.setUseJmx(true);
    broker.setPersistent(true);
    broker.setDataDirectory("target/activemq-data");
    broker.deleteAllMessages();
    broker.setAdvisorySupport(true);
    broker.addConnector(brokerUri);

    // configure expiration rate
    ActiveMQQueue queueName = new ActiveMQQueue(">");
    PolicyEntry entry = new PolicyEntry();
    entry.setDestination(queueName);
    entry.setExpireMessagesPeriod(1000);

    PolicyMap policyMap = new PolicyMap();
    policyMap.put(queueName, entry);
    broker.setDestinationPolicy(policyMap);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:QueueProducerQoSTest.java

示例2: createBroker

import org.apache.activemq.broker.region.policy.PolicyMap; //导入方法依赖的package包/类
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService service = new BrokerService();
   service.setDeleteAllMessagesOnStartup(true);

   service.setUseJmx(false);

   service.getSystemUsage().getStoreUsage().setLimit(200 * 1024);

   // allow destination to use 50% of store, leaving 50% for DLQ.
   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policy = new PolicyEntry();
   policy.setStoreUsageHighWaterMark(50);
   policyMap.put(queueDest, policy);
   policyMap.put(topicDest, policy);
   service.setDestinationPolicy(policyMap);

   connector = service.addConnector("tcp://localhost:0");
   return service;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:21,代码来源:PerDestinationStoreLimitTest.java

示例3: createBroker

import org.apache.activemq.broker.region.policy.PolicyMap; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:MemoryLimitTest.java

示例4: configureBroker

import org.apache.activemq.broker.region.policy.PolicyMap; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:23,代码来源:RequestReplyNoAdvisoryNetworkTest.java

示例5: setUp

import org.apache.activemq.broker.region.policy.PolicyMap; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
   super.setUp();
   responseReceived.set(0);
   respondentSendError.set(0);
   forwardFailures.set(0);
   sendsWithNoConsumers.set(0);
   networkConnectors.clear();
   advisoryConsumerConnections.clear();
   consumerDemandExists = new CountDownLatch(1);
   createBroker(new URI("broker:(tcp://localhost:0)/" + BROKER_A + "?persistent=false&useJmx=false")).setDedicatedTaskRunner(false);
   createBroker(new URI("broker:(tcp://localhost:0)/" + BROKER_B + "?persistent=false&useJmx=false")).setDedicatedTaskRunner(false);
   createBroker(new URI("broker:(tcp://localhost:0)/" + BROKER_C + "?persistent=false&useJmx=false")).setDedicatedTaskRunner(false);

   PolicyMap map = new PolicyMap();
   PolicyEntry defaultEntry = new PolicyEntry();
   defaultEntry.setSendAdvisoryIfNoConsumers(true);
   DeadLetterStrategy deadletterStrategy = new SharedDeadLetterStrategy();
   deadletterStrategy.setProcessNonPersistent(true);
   defaultEntry.setDeadLetterStrategy(deadletterStrategy);
   defaultEntry.setDispatchPolicy(new PriorityDispatchPolicy());
   map.put(new ActiveMQTempTopic(">"), defaultEntry);

   for (BrokerItem item : brokers.values()) {
      item.broker.setDestinationPolicy(map);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:28,代码来源:RequestReplyTempDestRemovalAdvisoryRaceTest.java

示例6: buildPolicyMap

import org.apache.activemq.broker.region.policy.PolicyMap; //导入方法依赖的package包/类
private PolicyMap buildPolicyMap() {
   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policyEntry = new PolicyEntry();
   policyEntry.setOptimizedDispatch(true);
   ConditionalNetworkBridgeFilterFactory networkBridgeFilterFactory = new ConditionalNetworkBridgeFilterFactory();
   networkBridgeFilterFactory.setReplayWhenNoConsumers(true);
   policyEntry.setNetworkBridgeFilterFactory(networkBridgeFilterFactory);
   policyEntry.setEnableAudit(false);
   policyMap.put(new ActiveMQQueue("Consumer.*.VirtualTopic.>"), policyEntry);
   return policyMap;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:12,代码来源:VirtualTopicNetworkClusterReactivationTest.java

示例7: createAndStartBroker

import org.apache.activemq.broker.region.policy.PolicyMap; //导入方法依赖的package包/类
private BrokerService createAndStartBroker(String name, String addr) throws Exception {
   BrokerService broker = new BrokerService();
   broker.setDeleteAllMessagesOnStartup(true);
   broker.setBrokerName(name);
   broker.addConnector(addr).setDiscoveryUri(new URI(MULTICAST_DEFAULT));
   broker.setUseJmx(false);

   NetworkConnector networkConnector = broker.addNetworkConnector(MULTICAST_DEFAULT);
   networkConnector.setDecreaseNetworkConsumerPriority(true);
   networkConnector.setDynamicOnly(dynamicOnly);
   networkConnector.setNetworkTTL(ttl);
   networkConnector.setSuppressDuplicateTopicSubscriptions(suppressDuplicateTopicSubs);
   networkConnector.setConsumerPriorityBase(BASE_PRIORITY);
   networkConnector.addStaticallyIncludedDestination(new ActiveMQTopic("BeStaticallyIncluded"));

   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policy = new PolicyEntry();
   policy.setDispatchPolicy(dispatchPolicy);
   // the audit will suppress the duplicates as it defaults to true so this test
   // checking for dups will fail. it is good to have it on in practice.
   policy.setEnableAudit(false);
   policyMap.put(new ActiveMQTopic(TOPIC_NAME), policy);
   broker.setDestinationPolicy(policyMap);
   broker.start();

   return broker;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:28,代码来源:NoDuplicateOnTopicNetworkTest.java

示例8: configureBroker

import org.apache.activemq.broker.region.policy.PolicyMap; //导入方法依赖的package包/类
private static void configureBroker(BrokerService broker) {
SystemUsage usage = new SystemUsage();
MemoryUsage mem = new MemoryUsage();
mem.setLimit(16*1024*1024);
usage.setMemoryUsage(mem);
broker.setSystemUsage(usage);
//DLQ strategy

      PolicyMap map = new PolicyMap();

      map.put(new ActiveMQQueue(">"), queuePolicy(">"));
      map.put(new ActiveMQTopic(">"), topicPolicy(">"));

      PolicyEntry qEntry = new PolicyEntry();
      qEntry.setQueue("signalk.>");

      IndividualDeadLetterStrategy strategy = new IndividualDeadLetterStrategy();
      strategy.setQueuePrefix("DLQ.");
      strategy.setUseQueueForQueueMessages(true);
      strategy.setProcessExpired(false);
      strategy.setProcessNonPersistent(true);
      qEntry.setDeadLetterStrategy(strategy);
      
      PrefetchRatePendingMessageLimitStrategy preFetchRate = new PrefetchRatePendingMessageLimitStrategy();
      preFetchRate.setMultiplier(2.0);
      qEntry.setPendingMessageLimitStrategy(preFetchRate);
      qEntry.setMessageEvictionStrategy(new OldestMessageEvictionStrategy());
      map.put(new ActiveMQQueue("signalk.>"), qEntry);

      broker.setDestinationPolicy(map);
  }
 
开发者ID:SignalK,项目名称:signalk-server-java,代码行数:32,代码来源:ActiveMqBrokerFactory.java

示例9: before

import org.apache.activemq.broker.region.policy.PolicyMap; //导入方法依赖的package包/类
@Override
public void before() throws Throwable {
    log.info("+++ BEFORE on JUnit Rule '" + id(Rule_Mats.class) + "', JMS and MATS:");
    String sysprop_matsTestActiveMq = System.getProperty(SYSPROP_MATS_TEST_ACTIVEMQ);

    // ::: Server (BrokerService)
    // ====================================

    // :? Do we have specific brokerUrl to connect to?
    if (sysprop_matsTestActiveMq == null) {
        // -> No - the system property was not set, hence start the in-vm broker.
        log.info("Setting up in-vm ActiveMQ BrokerService '" + BROKER_NAME + "' (i.e. the MQ server).");
        _amqServer = new BrokerService();
        _amqServer.setBrokerName(BROKER_NAME);
        _amqServer.setUseJmx(false); // No need for JMX registry.
        _amqServer.setPersistent(false); // No need for persistence (prevents KahaDB dirs from being created).
        _amqServer.setAdvisorySupport(false); // No need Advisory Messages.
        _amqServer.setUseShutdownHook(false);

        // :: Set Individual DLQ
        // Hear, hear: http://activemq.2283324.n4.nabble.com/PolicyMap-api-is-really-bad-td4284307.html
        PolicyMap destinationPolicy = new PolicyMap();
        _amqServer.setDestinationPolicy(destinationPolicy);
        PolicyEntry policyEntry = new PolicyEntry();
        policyEntry.setQueue(">");
        destinationPolicy.put(policyEntry.getDestination(), policyEntry);

        IndividualDeadLetterStrategy individualDeadLetterStrategy = new IndividualDeadLetterStrategy();
        individualDeadLetterStrategy.setQueuePrefix("DLQ.");
        policyEntry.setDeadLetterStrategy(individualDeadLetterStrategy);

        _amqServer.start();
    }
    else {
        // -> Yes, there is specified a brokerUrl to connect to, so we
        log.info("SKIPPING setup of in-vm ActiveMQ BrokerService (MQ server), since System Property '"
                + SYSPROP_MATS_TEST_ACTIVEMQ + "' was set (to [" + sysprop_matsTestActiveMq + "]).");
    }

    // ::: Client (ConnectionFactory)
    // ====================================

    // :: Find which broker URL to use
    String brokerUrl;
    if (sysprop_matsTestActiveMq == null) {
        brokerUrl = "vm://" + BROKER_NAME + "?create=false";
    }
    else if (SYSPROP_VALUE_LOCALHOST.equals(sysprop_matsTestActiveMq)) {
        brokerUrl = "tcp://localhost:61616";
    }
    else {
        brokerUrl = sysprop_matsTestActiveMq;
    }
    // :: Connect to the broker
    log.info("Setting up ActiveMQ ConnectionFactory (MQ client), brokerUrl: [" + brokerUrl + "].");
    _amqClient = new ActiveMQConnectionFactory(brokerUrl);
    RedeliveryPolicy redeliveryPolicy = _amqClient.getRedeliveryPolicy();
    // :: Only try redelivery once, since the unit tests does not need any more to prove that they work.
    redeliveryPolicy.setInitialRedeliveryDelay(500);
    redeliveryPolicy.setUseExponentialBackOff(false);
    redeliveryPolicy.setMaximumRedeliveries(1);

    // ::: MatsFactory
    // ====================================

    log.info("Setting up JmsMatsFactory.");
    _matsStringSerializer = new MatsDefaultJsonSerializer();
    // Allow for override in specialization classes, in particular the one with DB.
    _matsFactory = createMatsFactory(_matsStringSerializer, _amqClient);
    // For all test scenarios, it makes no sense to have a concurrency more than 1, unless explicitly testing that.
    _matsFactory.getFactoryConfig().setConcurrency(1);
    log.info("--- BEFORE done! JUnit Rule '" + id(Rule_Mats.class) + "', JMS and MATS.");
}
 
开发者ID:stolsvik,项目名称:mats,代码行数:74,代码来源:Rule_Mats.java


注:本文中的org.apache.activemq.broker.region.policy.PolicyMap.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。