我的微服务中, activemq 消费 一条消息的时候, 出了错, 结果导致了 那条消息就一直处于pending 状态,

  1. queue.user.545c2ed5-fee7-482a-bb59-564bbaa593f8_c5cdc461-4e9c-48c5-8684-6a81571114b8 1 1 0 0
  2.  
  3. 点击去是这样的:
  4.  
  5. Browse queue.user.545c2ed5-...
  6. Message ID Correlation ID Persistence Priority Redelivered Reply To Timestamp          Type Operations
  7. ID:dce4f74976e7-34120-1531388605944-1:4:1:1:1 Persistent 4 true          2018-07-12 09:43:31:554 UTC Delete

可以看到 pending  是1 , dequeue 是0 , 而消费者是1, 明明存在1个消费者, 但是却一直不消费, 不dequeue 是什么意思??  本想直接在那个管理界面上点击 delete 操作的, 但是想想,  哥也好歹是程序员, . 我决定写个程序来消费他..

  1. /**
  2. *
  3. * 队列操作
  4. */
  5. public static void consume() throws JMSException {
  6. Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
  7. String qu = null;
  8. qu = "queue.user.545c2ed5-fee7-482a-bb59-564bbaa593f8_c5cdc461-4e9c-48c5-8684-6a81571114b8";
  9. Queue queue = session.createQueue(qu);
  10. MessageConsumer consumer = session.createConsumer(queue);
  11. System.out.println("consumer = " + consumer);
  12. consumer.setMessageListener(new MessageListener() {
  13. @Override
  14. public void onMessage(Message message) {
  15. System.out.println("message00 ============ " + message);
  16. try {
  17. message.acknowledge();
  18. } catch (JMSException e) {
  19. e.printStackTrace();
  20. }
  21. }
  22. });
  23. }

程序运行没错, 但是, 我的 MessageListener 似乎不起作用,  message00 ============  始终不打印出来.  我也是郁闷了, 这么简单的程序都有错啊, 我写过很多次的好吧,  网上疯狂搜索一把, 好像大家都是这样写的啊..  坑爹了啊..

不同于topic, queue 是可以先生产, 后面再消费的吧,,queue 并没有生产者消费者时间先后顺序的限制, 难道哪里记错了?  各种找资料, 发现并不是这样的..

难不成activemq 已经报错了? 看下日志吧:

  1. 2018-04-13 05:11:03,574 CRIT Supervisor running as root (no user in config file)
  2. 2018-04-13 05:11:03,581 WARN Included extra file "/etc/supervisor/conf.d/activemq.conf" during parsing
  3. 2018-04-13 05:11:03,581 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
  4. 2018-04-13 05:11:03,744 INFO RPC interface 'supervisor' initialized
  5. 2018-04-13 05:11:03,744 CRIT Server 'unix_http_server' running without any HTTP authentication checking
  6. 2018-04-13 05:11:03,749 INFO supervisord started with pid 1
  7. 2018-04-13 05:11:04,751 INFO spawned: 'cron' with pid 16
  8. 2018-04-13 05:11:04,753 INFO spawned: 'activemq' with pid 17
  9. 2018-04-13 05:11:06,102 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  10. 2018-04-13 05:11:06,102 INFO success: activemq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  11. 2018-04-13 07:09:36,530 WARN received SIGTERM indicating exit request
  12. 2018-04-13 07:09:36,530 INFO waiting for cron, activemq to die
  13. 2018-04-13 07:09:37,533 INFO stopped: activemq (terminated by SIGTERM)
  14. 2018-04-13 07:09:37,534 INFO stopped: cron (terminated by SIGTERM)
  15. 2018-04-13 07:11:36,201 CRIT Supervisor running as root (no user in config file)
  16. 2018-04-13 07:11:36,201 WARN Included extra file "/etc/supervisor/conf.d/activemq.conf" during parsing
  17. 2018-04-13 07:11:36,201 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
  18. 2018-04-13 07:11:36,258 INFO RPC interface 'supervisor' initialized
  19. 2018-04-13 07:11:36,260 CRIT Server 'unix_http_server' running without any HTTP authentication checking
  20. 2018-04-13 07:11:36,260 INFO supervisord started with pid 1
  21. 2018-04-13 07:11:37,263 INFO spawned: 'cron' with pid 16
  22. 2018-04-13 07:11:37,265 INFO spawned: 'activemq' with pid 17
  23. 2018-04-13 07:11:38,737 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  24. 2018-04-13 07:11:38,738 INFO success: activemq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  25. 2018-05-03 03:42:11,945 WARN received SIGTERM indicating exit request
  26. 2018-05-03 03:42:11,959 INFO waiting for cron, activemq to die
  27. 2018-05-03 03:42:12,971 INFO stopped: activemq (terminated by SIGTERM)
  28. 2018-05-03 03:42:12,973 INFO stopped: cron (terminated by SIGTERM)
  29. 2018-05-03 03:44:23,724 CRIT Supervisor running as root (no user in config file)
  30. 2018-05-03 03:44:23,727 WARN Included extra file "/etc/supervisor/conf.d/activemq.conf" during parsing
  31. 2018-05-03 03:44:23,728 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
  32. 2018-05-03 03:44:23,824 INFO RPC interface 'supervisor' initialized
  33. 2018-05-03 03:44:23,824 CRIT Server 'unix_http_server' running without any HTTP authentication checking
  34. 2018-05-03 03:44:23,824 INFO supervisord started with pid 1
  35. 2018-05-03 03:44:24,830 INFO spawned: 'cron' with pid 16
  36. 2018-05-03 03:44:24,831 INFO spawned: 'activemq' with pid 17
  37. 2018-05-03 03:44:26,254 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  38. 2018-05-03 03:44:26,254 INFO success: activemq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  39. 2018-07-16 09:35:45,450 CRIT Supervisor running as root (no user in config file)
  40. 2018-07-16 09:35:45,458 WARN Included extra file "/etc/supervisor/conf.d/activemq.conf" during parsing
  41. 2018-07-16 09:35:45,458 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
  42. 2018-07-16 09:35:45,472 INFO RPC interface 'supervisor' initialized
  43. 2018-07-16 09:35:45,472 CRIT Server 'unix_http_server' running without any HTTP authentication checking
  44. 2018-07-16 09:35:45,472 INFO supervisord started with pid 1
  45. 2018-07-16 09:35:46,474 INFO spawned: 'cron' with pid 16
  46. 2018-07-16 09:35:46,475 INFO spawned: 'activemq' with pid 17
  47. 2018-07-16 09:35:47,773 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  48. 2018-07-16 09:35:47,773 INFO success: activemq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

似乎也并没有上面特别的, CRIT  是什么? 好像很严重的样子, 感觉还是可以忽略的吧..

http://activemq.2283324.n4.nabble.com/Messages-stuck-in-pending-state-in-queue-td4669239.html  好像是版本问题唉, 难道?

http://activemq.2283324.n4.nabble.com/Messages-are-kept-in-Pending-queue-for-durable-topic-subscribers-td4690015.html 看的晕晕的

https://stackoverflow.com/questions/7786086/difference-between-pending-messages-and-enqueue-counter-in-active-mq : 提到

  1. pending messages = number of messages CURRENTLY waiting for delivery in the destination (the current size of the queue)
  2.  
  3. enqueued messages = number of messages that where enqueued in the destination since the last statistic reset. This number can only rise.
  4.  
  5. dequeued messages = messages delivered from the destination to consumers. this number can be higher that the number of enqueued messages if a message was delivered to multiple consumers (topics).

好像并没什么卵用..

天啊, 明明两个消费者, 但是却一直不消费, 不dequeue 是几个意思?

仔细一看, 此时的消费者是2, 那就是说, 还有其他消费者?

  1. queue.user.545c2ed5-fee7-482a-bb59-564bbaa593f8_c5cdc461-4e9c-48c5-8684-6a81571114b8 1 2 0 0

突然意识到是我的微服务还在运行, 难道它阻塞了其他消费者对当前queue的消费? 赶紧把 微服务 关闭, 再次运行上面程序,  搞定了!

activemq 无法消费! consumers are alive when the messages are stuck !的更多相关文章

  1. springboot整合activemq(二),消费均匀分析

    问题分析:当如果多个消费者是什么情况呢 topic消费是友多个消费者的,是支持的,但是queue是支持,但是不能保证多个消费均匀消费,在分布式环境下怎么操作呢: 看案例: 在前面整合代码执行: 浏览器 ...

  2. ActiveMQ 集群(1)

    Queue consumer clusters(消费者集群): 简介: 同一个queue,如果一个消费者失效, 那么任何未经确认的消息将会被发送给queue上的其它消费者.如果一个消费者比其它消费者执 ...

  3. ActiveMQ静态网络链接(broker-to-broker)

    ActiveMQ的网络连接分为静态连接和动态连接.本章研究静态连接. 1.ActiveMQ的networkConnector是什么 在某些情况下,需要多个ActiveMQ的Broker做集群,那么就涉 ...

  4. 使用 ActiveMQ 实现JMS 异步调用

    目录 简介 启动 ActiveMQ 服务器 查看控制台 ActiveMQ 的消息通道 Queue Topic 比较 开发生产者和消费者 开发服务端(消费者) 开发客户端(生产者) 参考 简介 服务之间 ...

  5. 1.springboot+ActiveMQ

    1.项目结构如下 pom.xml文件如下 <dependencies> <dependency> <groupId>junit</groupId> &l ...

  6. 消息队列之activeMQ

    1.activeMQ的主要功能 实现高可用.高伸缩.高性能.易用和安全的企业级面向消息服务的系统 异步消息的消费和处理 控制消息的消费顺序 可以和Spring/springBoot整合简化编码 配置集 ...

  7. ActiveMQ(5.10.0) - Message Redelivery and DLQ Handling

    When messages expire on the ActiveMQ broker (they exceed their time-to-live, if set) or can’t be red ...

  8. 学习笔记-记ActiveMQ学习摘录与心得(二)

    上个周末被我玩过去了,罪过罪过,现在又是一个工作日过去啦,居然有些烦躁,估计这几天看的东西有点杂,晚上坐下来把自己首要工作任务总结总结.上篇学习博客讲了ActiveMQ的特性及安装部署,下面先把我以前 ...

  9. ActiveMQ的Destination高级特性

    1.    Composite Destinations  组合目的地 组合队列Composite Destinations : 允许用一个虚拟的destination代表多个destinations ...

随机推荐

  1. 第九节 java7JDK的常用封装类型

    一.Java Scanner类 /初始化一个 scanner 对象. Scanner scanner = new Scanner(System.in); //判断语法 boolean b = scan ...

  2. raid的一些简单知识

    日一.RAID定义RAID(Redundant Array of Independent Disk 独立冗余磁盘阵列)技术是加州大学伯克利分校1987年提出,最初是为了组合小的廉价磁盘来代替大的昂贵磁 ...

  3. QFileSystemModel中通过flags函数反应代码的层级思考

    Qt的Model/View设计中,有一些隐藏的代码,它们大多放在私有类里,对于类的作用非常关键,体现着Qt的整体设计思想.然而,由于它们比较隐蔽,学习起来比较繁琐,受到人们的忽视.然而,体现设计思想, ...

  4. css样式问题解决

    1.关于滚动条 (1)布局后由于写了 overflow-y: scroll; 在内容还没有超出就出现了滚动条. 我的解决方法是直接去掉了滚动条: .class::-webkit-scrollbar { ...

  5. 忘记Linux用户密码怎么办?

           忘记密码解决办法(centos6.5版本) 1.开机时,在此页面一直按ESC 2.然后进入以下界面时,按一下字母  “E”    键 (3)再按字母   “E”   键 (4)之后 输入 ...

  6. Beta版——爱阅APP功能说明书

    爱阅APP功能说明书 一.引言 通过Alpha发布和一些用户的反馈信息,了解到我们APP存在的问题.针对这些问题我们做了一些修改.以下内容是Beta版的功能说明书. 二.工具 安卓手机 爱阅APP安装 ...

  7. [LeetCode&Python] Problem 744. Find Smallest Letter Greater Than Target

    Given a list of sorted characters letters containing only lowercase letters, and given a target lett ...

  8. 【SpringBoot】息队列介绍和SpringBoot2.x整合RockketMQ、ActiveMQ

    ========================13.消息队列介绍和SpringBoot2.x整合RockketMQ.ActiveMQ ======================= 1.JMS介绍和 ...

  9. Java_初入IO流_字符流_Write-Read_小笔记

    package IO; import java.io.FileWriter; import java.io.IOException; class File_Writer { public static ...

  10. windows openssh 设置root 目录

    默认windows openssh 服务的root 目录是用户账户所在的目录(一般是administrator),但是我们可以通过修改sshd_config 重新修改路径 可选的修改方式 直接修改ss ...