activemq設置使用內存數和配置自動刪除無法消費的消息以及過期的消息


使用的activemq的版本為 apache-activemq-5.15.6

1、修改使用的內存

  actviemq消息量大之后可能會越來越慢,這可能是兩個問題,一是服務器分配內存太小,導致服務器處理消息慢,內存使用可以修改activemq小的bin文件夾內的env文件第

 35 行,ACTIVEMQ_OPTS_MEMORY="-Xms2G -Xmx4G" 這樣就可以增加內存了。

二是服務器如果使用kahadb那么文件可能會有過大的問題,需要調整配置文件。修改activemq下的config問價夾中的activemq.xml中的

122 <storeUsage>
123 <storeUsage limit="20 gb"/>
124 </storeUsage>

2、設置服務器自動刪除過期消息,死消息隊列中的消息

<destinationPolicy>
44 <policyMap>
45 <policyEntries>
46 <policyEntry topic=">" gcInactiveDestinations="true" inactiveTimoutBeforeGC ="30000">
47 <pendingMessageLimitStrategy>
48 <constantPendingMessageLimitStrategy limit="1000"/>
49 </pendingMessageLimitStrategy>
50 <deadLetterStrategy>
51 <sharedDeadLetterStrategy processExpired="false"/>
52 </deadLetterStrategy>
53 </policyEntry>
54 <policyEntry queue=">" optimizedDispatch="true" reduceMemoryFootprint="true">
55 <deadLetterStrategy>
56 <sharedDeadLetterStrategy processExpired="false"/>
57 </deadLetterStrategy>
58 </policyEntry>
59 </policyEntries>
60 </policyMap>
61 </destinationPolicy>

運行一段時間后在日志后可能會出現:

 Total of 8000 messages were discarded, since their destination was the dead letter queue ,這就表明這個配置已經起效。

 

另外activemq的日志文件為activemq/data/activemq.log。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM