关于ActiveMQ的点点滴滴

>>Producer flow-control
Note that, since the introduction of the new file cursor in ActiveMQ 5.x, non-persisted messages are shunted into the temporary file store to reduce the amount of memory used for non-persistent messaging. As a result, you may find that a queue's memoryLimit is never reached, as the cursor doesn't use very much memory. If you really do want to keep all your non-persistent messages in memory, and stop producers when the limit is reached, you should configure the <vmQueueCursor>.
==>
注意,由于AMQ5.x中引入了新的游标fileCursor,非持久化消息被分流到临时文件存储中,从而减少了非持久化消息对内存的使用。结果你会发现队列的内存限制(参数memoryLimit)从不会超限,因为游标
不会使用太多内存。如果你真正的想把所有的非持久消息放在内存中,当队列的内存限制达到时,停止生产者生产消息,你应该配置游标策略为【vmQueueCursor】。

>>流控制发生的条件:==>AMQ5.7.0默认采用【fileQueueCursor】
1、使用vmQueueCursor(与是否持久化无关)
2、队列的内存限制超过了设定的水位线值,参数【memoryLimit="1MB"】和【cursorMemoryHighWaterMark="85"】
   ===>是水位线超过预设的百分比时(区别是:持久化时,入队消息占用的是内存游标空间,而非持久化总是留队消息占用内存游标空间)

注意:

(1)、当流控制发生后,后续的消息是不能再进入队列中的,直到队列的内存使用量减少到水位线以下。
(2)、当流控制发生后,broker轮询监测是否有可用空间的间隔是30s。
(3)、换个角度,在采用【fileQueueCursor】时,也会发生流控制,当磁盘存储空间不够时。

>>策略配置样例:
<!-- use vmQueueCursor || fileQueueCursor -->
<pendingQueuePolicy>
<vmQueueCursor/>
</pendingQueuePolicy>





****************************
1、如果游标策略采用vmQueueCursor,无论持久化发送消息或者非持久化发送消息时,当设置了队列的memoryLimit非0时,并且producerFlowControl为开启,在水位线达到时会触发流控制发生;
2、如果游标策略采用fileQueueCursor,持久化发送消息时,如果storeUsage(磁盘空间)配置比较小时,该空间达到(变满)时,也会触发流控制发生,消息就不能入队了。
3、如果游标策略采用fileQueueCursor,非持久化发送消息时,如果tempUsage(磁盘空间)配置比较小时,该空间达到(变满)时,也会触发流控制发生,消息就不能入队了。

所有,建议选用fileQueueCursor,磁盘空间配置的尽可能大,即:存储持久化消息的参数【<storeUsage>】和存储非持久化消息的参数【<tempUsage>】。这两个参数仅占用磁盘空间。

总结:如果游标是vmQueueCursor,则使用的是内存空间,和memoryLimit有关;如果游标是fileQueueCursor,则使用的是磁盘空间,对持久化消息,和storeUsage有关,对于非持久化消息,则和tempUsage有关。
****************************

>>三种游标类型: storeCursor || vmQueueCursor || fileQueueCursor =>对于队列,默认是storeCursor

游标:storeCursor和fileQueueCursor类似(都是用的磁盘空间),但有点区别,是?==>前者是串行的,后者由vmQueueCursor衍生而来,是并行的。
fileQueueCursor是对vmQueueCursor的扩展

建议用fileQueueCursor,既有vmQueueCursor的优势,又弥补了其不足。

****************************

>> MQ对带宽的利用率:

*****************************

>>消息游标cursorMemoryUsage

>>Broker间路由消息时,KahaDB和LevelDB对带宽的利用率比对

猜你喜欢

转载自can-do.iteye.com/blog/2249196
今日推荐