摘要:網(wǎng)頁刪除想要刪除隊列中的消息,是可以通過的網(wǎng)頁來操作的。但是這種方式存在一個問題,就是當(dāng)消息多的時候點(diǎn)擊,頁面會卡死。在節(jié)點(diǎn)恢復(fù)正常之前,持久化隊列將不可用。所以這次我想要先清除指定隊列的消息即可。網(wǎng)上搜了一下版本的消息。
前因
在公司最新的項(xiàng)目上,由我們技術(shù)總監(jiān)搭了一套框架,其中有使用RabbitMq來監(jiān)聽監(jiān)聽寫事件,這也是我第一次使用RabbitMq。因?yàn)樵陂_發(fā)的過程中,有些事件會因?yàn)榇a的不完善消費(fèi)失敗,然后就會一直消費(fèi),然后一直報錯。當(dāng)bug修復(fù),把正確的代碼上傳到開發(fā)環(huán)境,原先遺留的問題消息任然存在,并且會阻塞隊列,讓之后的正常的消息無法讓系統(tǒng)正常的消費(fèi)。
網(wǎng)頁刪除想要刪除隊列中的消息,是可以通過RabbitMq的網(wǎng)頁來操作的。登錄上RabbitMQ Management之后,在 Queues 中打開指定的隊列:
然后在下方的 Delete / purge 中點(diǎn)擊 Delete 或者是 purge 都可以達(dá)到效果。
但是這種方式存在一個問題,就是當(dāng)消息多的時候點(diǎn)擊,頁面會卡死。即使沒有卡死也會出現(xiàn)如下對話框:
大概意思是找不到這個持久隊列,主節(jié)點(diǎn)已經(jīng)關(guān)閉或者是無法訪問。
現(xiàn)在只是小白階段,然后有點(diǎn)搞不懂,網(wǎng)上也沒有搜索到什么有用的答案。只找到一句話,來自:https://blog.csdn.net/u011973...
如果隊列的主節(jié)點(diǎn)不可用,則非鏡像隊列的行為取決于其持久性。在節(jié)點(diǎn)恢復(fù)正常之前,持久化隊列將不可用。在集群中其他節(jié)點(diǎn)上對主節(jié)點(diǎn)不可用的持久化隊列進(jìn)行任何操作都將失敗
沒有深究
重置RabbitMQ然后我就去網(wǎng)上百度了一下,如何使用命令操作,然后找到了下面的解決方法:
rabbitmqctl stop_app rabbitmqctl reset rabbitmqctl start_app
執(zhí)行了一次之后確實(shí)是有效的。重啟的RabbitMq,然后里面的消息也確實(shí)清空了。
然后我當(dāng)上述的情況再次發(fā)生,需要清空消息,這樣個時候我不想用這樣一看就很粗暴的方式來操作,而且這種方式不僅會清空消息,還會清空所有配置信息。所以這次我想要先清除指定隊列的消息即可。
刪除指定的隊列然后我找到了這個方法:
sudo rabbitmqctl purge_queue ${queue_name} 或 rabbitmqctl purge_queue ${queue_name} 或 rabbitmqctl -p ${vhostpath} purge_queue ${queue_name}
執(zhí)行報錯,說是找不到這個命令,給出的信息如下:
Error: could not recognise command Usage: rabbitmqctl [-n] [-q] [ ] Options: -n node -q Default node is "rabbit@server", where server is the local host. On a host named "server.example.com", the node name of the RabbitMQ Erlang node will usually be rabbit@server (unless RABBITMQ_NODENAME has been set to some non-default value at broker startup time). The output of hostname -s is usually the correct suffix to use after the "@" sign. See rabbitmq-server(1) for details of configuring the RabbitMQ broker. Quiet output mode is selected with the "-q" flag. Informational messages are suppressed when quiet mode is in effect. Commands: stop [ ] stop_app start_app wait reset force_reset rotate_logs join_cluster [--ram] cluster_status change_cluster_node_type disc | ram forget_cluster_node [--offline] update_cluster_nodes clusternode sync_queue queue cancel_sync_queue queue set_cluster_name name add_user delete_user change_password clear_password set_user_tags ... list_users add_vhost delete_vhost list_vhosts [ ...] set_permissions [-p ] clear_permissions [-p ] list_permissions [-p ] list_user_permissions set_parameter [-p ] clear_parameter [-p ] list_parameters [-p ] set_policy [-p ] [--priority ] [--apply-to ] clear_policy [-p ] list_policies [-p ] list_queues [-p ] [ ...] list_exchanges [-p ] [ ...] list_bindings [-p ] [ ...] list_connections [ ...] list_channels [ ...] list_consumers [-p ] status environment report eval close_connection trace_on [-p ] trace_off [-p ] set_vm_memory_high_watermark must be a member of the list [name, tracing]. The list_queues, list_exchanges and list_bindings commands accept an optional virtual host parameter for which to display results. The default value is "/". must be a member of the list [name, durable, auto_delete, arguments, policy, pid, owner_pid, exclusive_consumer_pid, exclusive_consumer_tag, messages_ready, messages_unacknowledged, messages, consumers, consumer_utilisation, memory, slave_pids, synchronised_slave_pids, status]. must be a member of the list [name, type, durable, auto_delete, internal, arguments, policy]. must be a member of the list [source_name, source_kind, destination_name, destination_kind, routing_key, arguments]. must be a member of the list [pid, name, port, host, peer_port, peer_host, ssl, ssl_protocol, ssl_key_exchange, ssl_cipher, ssl_hash, peer_cert_subject, peer_cert_issuer, peer_cert_validity, state, channels, protocol, auth_mechanism, user, vhost, timeout, frame_max, channel_max, client_properties, recv_oct, recv_cnt, send_oct, send_cnt, send_pend]. must be a member of the list [pid, connection, name, number, user, vhost, transactional, confirm, consumer_count, messages_unacknowledged, messages_uncommitted, acks_uncommitted, messages_unconfirmed, prefetch_count, global_prefetch_count].
實(shí)際上使用 rabbitmqctl -help 就能得到這些內(nèi)容。
可以看的出來,這里面已經(jīng) rabbitmqctl 所支持的命令都列了出來。其中并沒有 purge_queue 這個命令。不知道是不是版本問題還是怎么回事。
rabbitmqadmin然后在這里找到了 rabbitmqadmin 這個東西。官網(wǎng)地址:https://www.rabbitmq.com/mana... 。在上面看到了這么一行文字
Alternatively, you can download the version of rabbitmqadmin which corresponds with the management plugin version 3.7.17 from GitHub.
打開GitHub的鏈接:https://raw.githubusercontent.com/rabbitmq/rabbitmq-management/v3.7.17/bin/rabbitmqadmin 里面好像是 rabbitmqadmin 的代碼??戳艘幌侣窂剑瑅3.7.17。這個應(yīng)該是要對應(yīng)自己版本的。
rabbitmqctl status
查看版本:
[root@iZuf635fwy8k6ubk6r9yonZ ~]# rabbitmqctl status Status of node rabbit@iZuf635fwy8k6ubk6r9yonZ ... [{pid,3261}, {running_applications, [{rabbitmq_management,"RabbitMQ Management Console","3.3.5"}, {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.3.5"}, {webmachine,"webmachine","1.10.3-rmq3.3.5-gite9359c7"}, {mochiweb,"MochiMedia Web Server","2.7.0-rmq3.3.5-git680dba8"}, {rabbitmq_management_agent,"RabbitMQ Management Agent","3.3.5"}, {rabbit,"RabbitMQ","3.3.5"}, {mnesia,"MNESIA CXC 138 12","4.11"}, {os_mon,"CPO CXC 138 46","2.2.14"}, {amqp_client,"RabbitMQ AMQP Client","3.3.5"}, {inets,"INETS CXC 138 49","5.9.8"}, {xmerl,"XML parser","1.3.6"}, {sasl,"SASL CXC 138 11","2.3.4"}, {stdlib,"ERTS CXC 138 10","1.19.4"}, {kernel,"ERTS CXC 138 10","2.16.4"}]}, {os,{unix,linux}}, {erlang_version, "Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [async-threads:30] [hipe] [kernel-poll:true] "}, {memory, [{total,44920360}, {connection_procs,944512}, {queue_procs,911352}, {plugins,406328}, {other_proc,13412192}, {mnesia,200144}, {mgmt_db,391944}, {msg_index,95648}, {other_ets,1174432}, {binary,2676288}, {code,20229484}, {atom,711569}, {other_system,3766467}]}, {alarms,[]}, {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]}, {vm_memory_high_watermark,0.4}, {vm_memory_limit,1654662758}, {disk_free_limit,50000000}, {disk_free,16424939520}, {file_descriptors, [{total_limit,924},{total_used,9},{sockets_limit,829},{sockets_used,2}]}, {processes,[{limit,1048576},{used,396}]}, {run_queue,0}, {uptime,3716267}] ...done.
結(jié)果發(fā)現(xiàn)自己的版本竟然是3.3.5。修改路徑https://raw.githubusercontent.com/rabbitmq/rabbitmq-management/v3.7.17/bin/rabbitmqadmin 為https://raw.githubusercontent.com/rabbitmq/rabbitmq-management/v3.3.5/bin/rabbitmqadmin,訪問,顯示并沒有這個頁面。大概是版本太老了。網(wǎng)上搜了一下3.3.5版本的消息。發(fā)現(xiàn)這個版本大概是2014年左右的東西,時至今日已經(jīng)五年過去了,也太老了吧。
本文章一次沒有寫完,在我寫的過程中,項(xiàng)目提交給測試進(jìn)行部分測試,然后同事在test環(huán)境也安裝了一個RabbitMq。我登上去看了一下,嗯,是有 purge_queue 這個命令的??戳艘幌聇est的版本,3.6.8。果然還是版本問題。我之前一直操作的是dev服務(wù)器的東西,雖然本地也有安裝但是在本地進(jìn)行簡單的時候還是很好處理的,注釋掉代碼,然后重新運(yùn)行,消費(fèi)掉垃圾消息即可。
至于 rabbitmqadmin ,官網(wǎng)上有這么一段話:
Obtaining rabbitmqadmin
With the management plugin installed, browse to http://{hostname}:15672/cli/rabbitmqadmin to download. The tool supports
大概意思就可以通過訪問 http://{hostname}:15672/cli/rabbitmqadmin 來下載 rabbitmqadmin 。沒有深入研究。到此為止,后續(xù)可能會更新相關(guān)內(nèi)容。
發(fā)布文章的時候發(fā)現(xiàn),過長的思否對過長的url省略的后面的部分,就像是這樣:https://raw.githubusercontent...
。所以在上面就對url稍微處理了一下。
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://m.hztianpu.com/yun/75972.html
摘要:初步分析提升可從兩方面入手,一個是增加并發(fā)數(shù),其二是減少平均響應(yīng)時間。大部分的時間花在系統(tǒng)與數(shù)據(jù)庫的交互上,到這,便有了一個優(yōu)化的主題思路最大限度的降低平均響應(yīng)時間。不要輕易否定一項(xiàng)公認(rèn)的技術(shù)真理,要拿數(shù)據(jù)說話。 本文最早發(fā)表于個人博客:PylixmWiki 應(yīng)項(xiàng)目的需求,我們使用tornado開發(fā)了一個api系統(tǒng),系統(tǒng)開發(fā)完后,在8核16G的虛機(jī)上經(jīng)過壓測qps只有200+。與我們當(dāng)...
摘要:本文基于的插件,針對進(jìn)行簡單的測試。包括協(xié)議的介紹,的安裝配置開啟插件及基于進(jìn)行的測試。協(xié)議是基于發(fā)布訂閱模型的物聯(lián)網(wǎng)消息傳遞協(xié)議。對傳輸消息有三種服務(wù)質(zhì)量最多一次,這一級別會發(fā)生消息丟失或重復(fù),消息發(fā)布依賴于底層網(wǎng)絡(luò)。 ...
摘要:盡可能地將數(shù)據(jù)寫入,例如創(chuàng)建設(shè)置的都會將數(shù)據(jù)立即的寫入再來看看文檔怎么描述的看看這可愛的默認(rèn)值我們終于知道了當(dāng)我們不做任何設(shè)置時,默認(rèn)采用的是方式顯而易見,使用方式能最大限度的減少與的交互,而在大多數(shù)場景下都是沒有問題的。 0.問題背景 此次問題源于一次挺嚴(yán)重的生產(chǎn)事故:客戶的訂單被重復(fù)生成了,而出問題的代碼其實(shí)很簡單: // .... redisLockUtil.lock(membe...
閱讀 1869·2021-11-11 11:02
閱讀 1786·2021-09-22 15:55
閱讀 2599·2021-09-22 15:18
閱讀 3551·2019-08-29 11:26
閱讀 3820·2019-08-26 13:43
閱讀 2996·2019-08-26 13:32
閱讀 984·2019-08-26 10:55
閱讀 1027·2019-08-26 10:27