移动网站营销,企业为什么要培训,新手如何做网站的教程,苏州市城乡建设档案馆网站Active MQ 06
Request/Response模型实现
QueueRequestor
同步阻塞
TemporaryQueue
异步监听#xff0c;当消息过多时会创建响应的临时queue
JMSCorrelationID 消息属性
异步监听#xff0c;公用queue
调优总结
Topic加强 可追溯消息
http://activemq.apache.org/re…Active MQ 06
Request/Response模型实现
QueueRequestor
同步阻塞
TemporaryQueue
异步监听当消息过多时会创建响应的临时queue
JMSCorrelationID 消息属性
异步监听公用queue
调优总结
Topic加强 可追溯消息
http://activemq.apache.org/retroactive-consumer.html
避免topic下错过消息
消费者设置 Destination topic session.createTopic(tpk?consumer.retroactivetrue);Summary of Available Recovery Policies
Policy NameSample ConfigurationDescriptionFixedSizedSubscriptionRecoveryPolicyKeep a fixed amount of memory in RAM for message history which is evicted in time order.FixedCountSubscriptionRecoveryPolicyKeep a fixed count of last messages.LastImageSubscriptionRecoveryPolicyKeep only the last message.NoSubscriptionRecoveryPolicyDisables message recovery.QueryBasedSubscriptionRecoveryPolicyPerform a user specific query mechanism to load any message they may have missed. Details on message selectors are available hereTimedSubscriptionRecoveryPolicyKeep a timed buffer of messages around in memory and use that to recover new subscriptions. Recovery time is in milliseconds.RetainedMessageSubscriptionRecoveryPolicyKeep the last message with ActiveMQ.Retain property set to true
保留固定字节的消息
policyEntry topicsubscriptionRecoveryPolicyfixedSizedSubscriptionRecoveryPolicy maximumSize1024//subscriptionRecoveryPolicy
/policyEntry
保留固定数量的消息
policyEntry topicsubscriptionRecoveryPolicyfixedCountSubscriptionRecoveryPolicy maximumSize100//subscriptionRecoveryPolicy
/policyEntry
保留时间 subscriptionRecoveryPolicytimedSubscriptionRecoveryPolicy recoverDuration60000 / /subscriptionRecoveryPolicy保留最后一条 subscriptionRecoveryPolicylastImageSubscriptionRecoveryPolicy//subscriptionRecoveryPolicy慢速消费
SlowConsumerStrategy
对于慢消费者broker会启动一个后台线程用来检测所有的慢速消费者并定期的关闭慢消费者。 AbortSlowConsumerStrategy abortConnection中断慢速消费者慢速消费将会被关闭。
slowConsumerStrategy abortSlowConsumerStrategy abortConnectionfalse/!-- 不关闭底层链接 --
/slowConsumerStrategyAbortSlowConsumerStrategy maxTimeSinceLastAck如果慢速消费者最后一个ACK距离现在的时间间隔超过阀值则中断慢速消费者。
slowConsumerStrategy abortSlowConsumerStrategy maxTimeSinceLastAck30000/!-- 30秒滞后 --
/slowConsumerStrategyPendingMessageLimitStrategy消息限制策略面向慢消费者
http://activemq.apache.org/slow-consumer-handling
此策略只对Topic有效只对未持久化订阅者有效当通道中有大量的消息积压时broker可以保留的消息量。为了防止Topic中有慢速消费者导致整个通道消息积压。 ConstantPendingMessageLimitStrategy保留固定条数的消息如果消息量超过limit将使用消息剔除策略移除消息。
policyEntry topicORDERS. !-- lets force old messages to be discarded for slow consumers -- pendingMessageLimitStrategy constantPendingMessageLimitStrategy limit50/ /pendingMessageLimitStrategy
/policyEntryPrefetchRatePendingMessageLimitStrategy保留prefetchSize倍数条消息。
!-- 若prefetchSize为100则保留2.5 * 100条消息 --
prefetchRatePendingMessageLimitStrategy multiplier2.5/消息堆积内存上涨
检查消息是否持久化检查消息 消费速度与生产速度调整xms xmx参数
磁盘满
当非持久化消息堆积到一定程度ActiveMQ会将非持久化消息写入临时文件但是在重启的时候不会恢复
当存储持久化数据的磁盘满了的时候
持久化消息
生产者阻塞消费正常当消费一部分消息后腾出空间生产者继续
非持久化消息
由于临时文件造成磁盘满了生产者阻塞消费异常无法提供服务
开启事务
在发送非持久化消息的时候可以有效防止消息丢失
prefetchSize影响消费倾斜
慢速消费的时候可以将prefetchSize设为1每次取一条
prefetchSize造成消费者内存溢出
AUTO_ACKNOWLEDGE造成消息丢失/乱序
消息消费失败后无法复原消息可以手动ack 避免broker把消息自动确认删除
receive()方法接受到消息后立即确认
listener 的onmessage方法执行完毕才会确认
手动ack的时候要等connection断开 才会重新推送给其他的consumer所以有可能会导致消费顺序错乱
exclusive 和selector有可能造成消息堆积