activemq 沒法消費! consumers are alive when the messages are stuck !

個人微服務中, activemq 消費 一條消息的時候, 出了錯, 結果致使了 那條消息就一直處於pending 狀態, html

queue.user.545c2ed5-fee7-482a-bb59-564bbaa593f8_c5cdc461-4e9c-48c5-8684-6a81571114b8    1    1    0    0 點擊去是這樣的: Browse queue.user.545c2ed5-... Message ID Correlation ID Persistence Priority Redelivered Reply To Timestamp          Type Operations 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 操做的, 可是想一想,  哥也好歹是程序員, . 我決定寫個程序來消費他..程序員

/** * * 隊列操做 */
    public static void consume() throws JMSException { Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); String qu = null; qu = "queue.user.545c2ed5-fee7-482a-bb59-564bbaa593f8_c5cdc461-4e9c-48c5-8684-6a81571114b8";
        Queue queue = session.createQueue(qu); MessageConsumer consumer = session.createConsumer(queue);         System.out.println("consumer = " + consumer); consumer.setMessageListener(new MessageListener() { @Override public void onMessage(Message message) { System.out.println("message00 ============ " + message); try { message.acknowledge(); } catch (JMSException e) { e.printStackTrace(); } } }); }

程序運行沒錯, 可是, 個人 MessageListener 彷佛不起做用,  message00 ============  始終不打印出來.  我也是鬱悶了, 這麼簡單的程序都有錯啊, 我寫過不少次的好吧,  網上瘋狂搜索一把, 好像你們都是這樣寫的啊..  坑爹了啊.. session

不一樣於topic, queue 是能夠先生產, 後面再消費的吧,,queue 並無生產者消費者時間前後順序的限制, 難道哪裏記錯了?  各類找資料, 發現並非這樣的..ide

 

難不成activemq 已經報錯了? 看下日誌吧: 微服務

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

彷佛也並無上面特別的, CRIT  是什麼? 好像很嚴重的樣子, 感受仍是能夠忽略的吧..this

http://activemq.2283324.n4.nabble.com/Messages-stuck-in-pending-state-in-queue-td4669239.html  好像是版本問題唉, 難道?spa

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

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

pending messages = number of messages CURRENTLY waiting for delivery in the destination (the current size of the queue) enqueued messages = number of messages that where enqueued in the destination since the last statistic reset. This number can only rise. 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).

好像並沒什麼卵用..code

 

天啊, 明明兩個消費者, 可是卻一直不消費, 不dequeue 是幾個意思? 

仔細一看, 此時的消費者是2, 那就是說, 還有其餘消費者? 

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

 

忽然意識到是個人微服務還在運行, 難道它阻塞了其餘消費者對當前queue的消費? 趕忙把 微服務 關閉, 再次運行上面程序,  搞定了! 

相關文章
相關標籤/搜索