公司做了一个产品用到了消息中间件activemq,我们今天做了一下压力测试

但是由于生产过快消费过慢,造成了activemq挂掉,排查日志及网上百度发现是因为data文件夹下面

有一个db.data文件过大超过了4G造成activemq卡死

我们决定配置死信队列保证在一定时间内不消费的消息自动加入到死信队列,实现自动清除

下面我贴出完整的配置文件

<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<!-- START SNIPPET: example -->
<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

<!-- Allows us to use system properties as variables in this configuration file -->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>file:${activemq.conf}/credentials.properties</value>
        </property>
    </bean>

<!-- Allows log searching in hawtio console -->
    <bean id="logQuery" class="org.fusesource.insight.log.log4j.Log4jLogQuery"
          lazy-init="false" scope="singleton"
          init-method="start" destroy-method="stop">
    </bean>

<!--
        The <broker> element is used to configure the ActiveMQ broker.
    -->
    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">

<destinationPolicy>
            <policyMap>
              <policyEntries>
              <policyEntry queue=">" gcInactiveDestinations="true" inactiveTimoutBeforeGC="30000">
                <deadLetterStrategy>
                    <sharedDeadLetterStrategy processExpired="false" />
                </deadLetterStrategy>
              </policyEntry>
                <policyEntry topic=">" >
                    <!-- The constantPendingMessageLimitStrategy is used to prevent
                         slow topic consumers to block producers and affect other consumers
                         by limiting the number of messages that are retained
                         For more information, see:
                         http://activemq.apache.org/slow-consumer-handling.html
                    -->
                  <pendingMessageLimitStrategy>
                    <constantPendingMessageLimitStrategy limit="1000"/>
                  </pendingMessageLimitStrategy>
                </policyEntry>
              </policyEntries>
            </policyMap>
        </destinationPolicy>

<!--
            The managementContext is used to configure how ActiveMQ is exposed in
            JMX. By default, ActiveMQ uses the MBean server that is started by
            the JVM. For more information, see:

http://activemq.apache.org/jmx.html
        -->
        <managementContext>
            <managementContext createConnector="false"/>
        </managementContext>

<!--
            Configure message persistence for the broker. The default persistence
            mechanism is the KahaDB store (identified by the kahaDB tag).
            For more information, see:

http://activemq.apache.org/persistence.html
        -->
        <persistenceAdapter>
            <kahaDB directory="${activemq.data}/kahadb"/>
        </persistenceAdapter>

<!--
            The systemUsage controls the maximum amount of space the broker will
            use before disabling caching and/or slowing down producers. For more information, see:
            http://activemq.apache.org/producer-flow-control.html
          -->
          <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage percentOfJvmHeap="70" />
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="100 gb"/>
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="50 gb"/>
                </tempUsage>
            </systemUsage>
        </systemUsage>

<!--
            The transport connectors expose ActiveMQ over a given protocol to
            clients and other brokers. For more information, see:

http://activemq.apache.org/configuring-transports.html
        -->
        <transportConnectors>
            <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        </transportConnectors>

<!-- destroy the spring context on shutdown to stop jetty -->
        <shutdownHooks>
            <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
        </shutdownHooks>

<plugins>
            <!-- 86,400,000ms = 1 day -->
            <timeStampingBrokerPlugin ttlCeiling="30000" zeroExpirationOverride="30000" />

<!-- <discardingDLQBrokerPlugin dropAll="true" dropTemporaryTopics="true" dropTemporaryQueues="true" />-->
        </plugins>
    </broker>

<!--
        Enable web consoles, REST and Ajax APIs and demos
        The web consoles requires by default login, you can disable this in the jetty.xml file

Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
    -->
    <import resource="jetty.xml"/>

</beans>
<!-- END SNIPPET: example -->

Mqtt设置消息超时时间相关推荐

  1. RabbitMQ消息超时时间、队列消息超时时间、队列超时时间

    欢迎来到梁钟霖个人博客网站.本个人博客网站提供最新的站长新闻,各种互联网资讯. 还提供个人博客模板,最新最全的java教程,java面试题.在此我将尽我最大所能将此个人博客网站做的最好! 谢谢大家,愿 ...

  2. php session超时时间_php怎么设置session超时时间

    [摘要] PHP即"超文本预处理器",是一种通用开源脚本语言.PHP是在服务器端执行的脚本语言,与C语言类似,是常用的网站编程语言.PHP独特的语法混合了C.Java.Perl以及 ...

  3. C# 的tcp Socket设置自定义超时时间

    简单的c# TCP通讯(TcpListener) C# 的TCP Socket (同步方式) C# 的TCP Socket (异步方式) C# 的tcp Socket设置自定义超时时间 C# TCP ...

  4. Android okhttp3使用实例,OKhttp设置请求超时时间,okgo使用demo

    1.导入OKhttp依赖 compile 'com.squareup.okhttp3:okhttp:3.4.1' 2.创建请求工具类 三个工具类 /*** 作者:created by meixi* 邮 ...

  5. 熟练掌握如何设置空闲超时时间.

    熟练掌握如何设置空闲超时时间.   配置实例一: Aiko(config)#exit Aiko# *Mar 1 00:20:11.231: %SYS-5-CONFIG_I: Configured fr ...

  6. java session时间_java session时长问题,java设置session超时时间实例

    java session超时设置你知道应该如何设置吗?下面要给大家带来的实例就是和java设置session超时时间相关的内容,一起来看看具体实现方式吧. 一般的系统登陆了之后,都会有设置一个当前的s ...

  7. 【教程】Windows通过注册表方式设置TCP超时时间

    Windows 通过注册表设置 TCP超时时间: 1.打开"开始"菜单,输入"regedit"并打开注册表编辑器 2.在注册表编辑器中,导航到 HKEY LOC ...

  8. mysql 事务 超时时间_设置事务超时时间的问题及数据库update和锁

    Oracle的update语句问题: update config t set t.value =1 where t.key='DB_ KEY' 或者: select * from config t w ...

  9. apache 设置session超时时间_深入分析 Session 和 Cookie,看这篇就对了

    点击上方 "程序员小乐"关注, 星标或置顶一起成长 第一时间与你相约 每日英文 Promise yourself to be so strong that nothing can ...

最新文章

  1. 揭密Oracle之 七种武器
  2. ASP 投票系统所用技术小结
  3. python实现http请求并发_Python使用grequests并发发送请求
  4. 面试官:你知道怎么求素数吗?
  5. iOS 8 Xcode6 设置Launch Image 启动图片转
  6. python 爬虫基础(一)Beautifulsoup基础介绍
  7. mysql身份证校验码_通过SQL校验身份证号码是否正确
  8. 我的世界学园都市java_我的世界学园都市地图
  9. 怎么用python下载网易云_使用Python实现下载网易云音乐的高清MV
  10. 【解决】jsPDF之长图片生成PDF(分页,失真)
  11. vue2 学习之路 常见的指令!
  12. 大整数加减乘除的实现
  13. Json字符串的转换
  14. Github安卓流行布局开源库
  15. Spring的IOC/DI
  16. repeater 控件ajax绑定数据源,ASP.NET数据绑定之Repeater控件
  17. Redis——热点key问题
  18. 前端vue项目打包部署
  19. 用手机作为显示屏打造树莓派的移动电脑形态
  20. 健康睡眠,提高工作效率

热门文章

  1. 操作系统面试题(三)
  2. PCL点云处理之计算两平面交线(五十一)
  3. XMind Mac高阶玩法,原来XMind 还可以这么玩
  4. 衡量CPU的三个指标:CPU Utilization、Load Average和Context Switch Rate
  5. stateflow入门学习笔记
  6. MATLAB rng(0)
  7. 华为笔试4.20记录
  8. Asp.net中GridView使用详解(很全,很经典 转来的)
  9. OSPF协议原理与配置方法
  10. jboss的安装以及配置