Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
超出ActiveMQ内存限制_Activemq - Fatal编程技术网

超出ActiveMQ内存限制

超出ActiveMQ内存限制,activemq,Activemq,我尝试将ActiveMQ配置为以下行为:当代理超出其内存限制时,它应该将消息存储在持久性存储中。如果需要,请使用以下配置: BrokerService broker = new BrokerService(); broker.setBrokerName("activemq"); KahaDBPersistenceAdapter persistence = new KahaDBPersistenceAdapter(); persistence.setDirector

我尝试将ActiveMQ配置为以下行为:当代理超出其内存限制时,它应该将消息存储在持久性存储中。如果需要,请使用以下配置:

    BrokerService broker = new BrokerService();
    broker.setBrokerName("activemq");
    KahaDBPersistenceAdapter persistence = new KahaDBPersistenceAdapter();
    persistence.setDirectory(new File(config.getProperty("amq.persistenceDir", "amq")));
    broker.setPersistenceAdapter(persistence);
    broker.setVmConnectorURI(new URI("vm://activemq"));
    broker.getSystemUsage().getMemoryUsage().setLimit(64 * 1024 * 1024L);
    broker.getSystemUsage().getStoreUsage().setLimit(1024 * 1024 * 1024 * 100L);
    broker.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 1024 * 100L);
    PolicyEntry policyEntry = new PolicyEntry();
    policyEntry.setCursorMemoryHighWaterMark(50);
    policyEntry.setExpireMessagesPeriod(0L);
    policyEntry.setPendingDurableSubscriberPolicy(new StorePendingDurableSubscriberMessageStoragePolicy());
    policyEntry.setMemoryLimit(64 * 1024 * 1024L);
    policyEntry.setProducerFlowControl(false);
    broker.setDestinationPolicy(new PolicyMap());
    broker.getDestinationPolicy().setDefaultEntry(policyEntry);
    broker.setUseJmx(true);
    broker.setPersistent(true);
    broker.start();
然而,这是行不通的。ActiveMQ仍然消耗存储完整队列所需的内存。我还尝试删除PolicyEntry,这导致代理在达到内存限制后停止生产者。我在文档中找不到任何关于我做错了什么的信息。

我们使用a并按如下方式设置内存限制…这将所有队列的内存量限制为100MB

   <destinationPolicy>
        <policyMap>
            <policyEntries>
                <policyEntry queue=">" producerFlowControl="false" memoryLimit="100mb">
                    <pendingQueuePolicy>
                        <storeCursor/>
                    </pendingQueuePolicy>
                </policyEntry>
            </policyEntries>
        </policyMap>
    </destinationPolicy>

确保您设置了策略应针对的“目的地”…在我的XML示例中,这是使用
queue=“>”
完成的,但您的示例使用的是
new PolicyMap()
…尝试调用
policyEntry.setQueue(“>”
),以应用于所有队列或将特定目的地添加到策略映射中,等等

有关完整示例,请参阅此测试


我确实使用存储游标。我没有通过XML配置ActiveMQ。我尝试了这两种方法:policyEntry.setPendingQueuePolicy(new StorePendingQueueMessageStoragePolicy());policyEntry.setPendingDurableSubscriberPolicy(新存储PendingDurableSubscriberMessageStoragePolicy());并通过XML进行配置。但是没有任何帮助。不清楚您使用的是哪一个游标…但是我们在使用VM游标时遇到了相同的问题,这解决了它…无论您是否使用XML/Java来配置它,基本问题听起来是一样的…我的示例显示了我们是如何解决它的…可能它的不同想法我将大约10Gb的消息放入队列中,发现队列虽然超过了指定的内存限制约7倍,但保留了该因子常量,即不抛出OutOfMemoryException。将带有-Xmx标志的JVM限制为512 mb会导致OOME。我认为这是有问题的,但至少我可以肯定,若我给队列分配1Gb,JVM不会失败。