我正在调试一些使用Apache POI从Microsoft Office文档中提取数据的Java代码.有时,当内存不足时,它会遇到大文档和POI崩溃.此时,它会尝试将错误发布到RabbitMQ,以便其他组件可以知道此步骤失败并采取适当的操作.但是,当它尝试发布到队列时,它会得到一个com.rabbitmq.client.AlreadyClosedException (clean connection shutdown; reason: Attempt to use closed channel).
这是错误处理程序代码:
try {
//Extraction and indexing code
}
catch(Throwable t) {
// Something went wrong! We'll publish the error and then move on with
// our lives
System.out.println("Error received when indexing message: ");
t.printStackTrace();
System.out.println();
String error = PrintExc.format(t);
message.put("error", error);
if(mime == null) {
mime = "application/vnd.unknown";
}
message.put("mime", mime);
publish("IndexFailure", "", MessageProperties.PERSISTENT_BASIC, message);
}
Run Code Online (Sandbox Code Playgroud)
为了完整性,这是发布方法:
private void publish(String exch, String route,
AMQP.BasicProperties props, Map<String, …Run Code Online (Sandbox Code Playgroud) 我一直试图找出使用鼠兔时应该使用哪种形式的连接,据我所知,我有两种选择.
无论是BlockingConnection或SelectConnection,但是我真的不知道有关之间的差异这两个(即什么是BlockingConnection阻止?多)
pika说的文件SelectConnection是连接到兔子的首选方式,因为它提供了"多种事件通知方法,包括select,epoll,kqueue和poll".
所以我想知道这两种不同类型的连接有什么含义?
PS:我知道我不应该在标题中添加标签,但在这种情况下,我认为它确实有助于澄清问题.
我是RabbitMQ的初学者,我在启用管理插件方面遇到了一些问题.rabbitmq服务器启动并运行,但是当我尝试启用插件时,我在Windows命令提示符下得到了这个:
C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.1.5\sbin>rabbitmq-plugi
ns.bat enable rabbitmq_management
{error_logger,{{2013,9,6},{12,46,51}},"Failed to create cookie file 'u:/.erlang.
cookie': enoent",[]}
{error_logger,{{2013,9,6},{12,46,51}},crash_report,[[{initial_call,{auth,init,['
Argument__1']}},{pid,<0.19.0>},{registered_name,[]},{error_info,{exit,{"Failed t
o create cookie file 'u:/.erlang.cookie': enoent",[{auth,init_cookie,0,[{file,"a
uth.erl"},{line,285}]},{auth,init,1,[{file,"auth.erl"},{line,139}]},{gen_server,
init_it,6,[{file,"gen_server.erl"},{line,304}]},{proc_lib,init_p_do_apply,3,[{fi
le,"proc_lib.erl"},{line,239}]}]},[{gen_server,init_it,6,[{file,"gen_server.erl"
},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]}
},{ancestors,[net_sup,kernel_sup,<0.10.0>]},{messages,[]},{links,[<0.17.0>]},{di
ctionary,[]},{trap_exit,true},{status,running},{heap_size,610},{stack_size,27},{
reductions,964}],[]]}
{error_logger,{{2013,9,6},{12,46,51}},supervisor_report,[{supervisor,{local,net_
sup}},{errorContext,start_error},{reason,{"Failed to create cookie file 'u:/.erl
ang.cookie': enoent",[{auth,init_cookie,0,[{file,"auth.erl"},{line,285}]},{auth,
init,1,[{file,"auth.erl"},{line,139}]},{gen_server,init_it,6,[{file,"gen_server.
erl"},{line,304}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}
]}]}},{offender,[{pid,undefined},{name,auth},{mfargs,{auth,start_link,[]}},{rest
art_type,permanent},{shutdown,2000},{child_type,worker}]}]}
{error_logger,{{2013,9,6},{12,46,51}},supervisor_report,[{supervisor,{local,kern
el_sup}},{errorContext,start_error},{reason,{shutdown,{failed_to_start_child,aut
h,{"Failed to create cookie file 'u:/.erlang.cookie': enoent",[{auth,init_cookie
,0,[{file,"auth.erl"},{line,285}]},{auth,init,1,[{file,"auth.erl"},{line,139}]},
{gen_server,init_it,6,[{file,"gen_server.erl"},{line,304}]},{proc_lib,init_p_do_
apply,3,[{file,"proc_lib.erl"},{line,239}]}]}}}},{offender,[{pid,undefined},{nam
e,net_sup},{mfargs,{erl_distribution,start_link,[]}},{restart_type,permanent},{s
hutdown,infinity},{child_type,supervisor}]}]}
{error_logger,{{2013,9,6},{12,46,51}},crash_report,[[{initial_call,{application_
master,init,['Argument__1','Argument__2','Argument__3','Argument__4']}},{pid,<0.
9.0>},{registered_name,[]},{error_info,{exit,{{shutdown,{failed_to_start_child,n
et_sup,{shutdown,{failed_to_start_child,auth,{"Failed to create cookie file 'u:/
.erlang.cookie': enoent",[{auth,init_cookie,0,[{file,"auth.erl"},{line,285}]},{a
uth,init,1,[{file,"auth.erl"},{line,139}]},{gen_server,init_it,6,[{file,"gen_ser
ver.erl"},{line,304}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,
239}]}]}}}}},{kernel,start,[normal,[]]}},[{application_master,init,4,[{file,"app
lication_master.erl"},{line,133}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.
erl"},{line,239}]}]}},{ancestors,[<0.8.0>]},{messages,[{'EXIT',<0.10.0>,normal}]
},{links,[<0.8.0>,<0.7.0>]},{dictionary,[]},{trap_exit,true},{status,running},{h
eap_size,610},{stack_size,27},{reductions,150}],[]]}
{error_logger,{{2013,9,6},{12,46,51}},std_info,[{application,kernel},{exited,{{s
hutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,auth,{"F
ailed …Run Code Online (Sandbox Code Playgroud) 我没有找到一个现有的帖子问这个但是如果我错过它就道歉.
我试图让我的头部微服务,并遇到使用RabbitMQ的文章.我很困惑为什么需要RabbitMQ.服务是否意图使用web api与外界通信,RabbitMQ是否相互通信?
我正在尝试在小型VPS(512mb RAM)上运行RabbitMQ以及Nginx和其他一些程序.我已经能够毫无困难地调整其他所有内存的使用情况,但我似乎无法让RabbitMQ使用更少的RAM.
我想我需要减少Erlang用于RabbitMQ的线程数,但是我无法让它工作.我也尝试将vm_memory_high_watermark一些不同的值设置为低于默认值(40%),甚至低至5%.
部分问题可能是VPS提供程序(MediaTemple)允许我查看我分配的内存,因此当使用free或top时,它表明服务器大约有900mb.
有关减少RabbitMQ内存使用量或限制Erlang将创建的线程数的建议吗?我相信Erlang正在使用30个线程,基于我在进程命令中看到的-A30标志.
理想情况下,我希望RabbitMQ内存使用率低于100mb.
编辑:
随着vm_memory_high_watermark设置为5%(或在配置文件中0.05),在RabbitMQ的日志报告的RabbitMQ的内存限制设置为51MB.我不确定51mb来自哪里.当前VPS分配的内存为924mb,因此其中5%应为46mb左右.
根据启动RabbitMQ之前的htop/free,我坐着大约453mb的二手ram,在启动RabbitMQ之后,我大约650mb.增加近200mb.可能是200MB是RabbitMQ运行的下限吗?
编辑2
下面是启动RabbitMQ之前和之后ps aux和free的一些截图,以及显示RabbitMQ启动时内存峰值的图表.
编辑3
我还检查没有启用插件,它没有什么区别.似乎我拥有的插件(管理及其先决条件)仅增加了大约8mb的ram使用量.
编辑4
我不再需要使用此服务器进行测试,但是,有一个conf设置delegate_count被设置为默认值16.据我所知,这为rabbitmq产生了16个sup-procs.在较小的服务器上降低此数字可能有助于减少内存占用.不知道这是否真的有效,或者它如何影响性能,但这是值得尝试的.
我们有一个基于rabbitMQ和的分布式架构Celery.我们可以并行启动多个任务而不会出现任何问题.可扩展性很好.
现在我们需要远程控制任务:PAUSE,RESUME,CANCEL.我们发现的唯一解决方案是在Celery任务中对DB请求后回复命令的另一个任务进行RPC调用.Celery任务和RPC任务不在同一台机器上,只有RPC任务可以访问数据库.
您是否有任何建议如何改进它并轻松地与正在进行的任务沟通?谢谢
编辑:
事实上,我们想做的事情如下图所示.这很容易进行Blue配置或者Orange,但是我们不知道如何同时进行这两种配置.
工人正在订阅一个共同点Jobs queue,每个工人都有自己Admin queue在交易所申报的.
编辑:
如果这是不可能的Celery,我愿意接受其他框架的解决方案python-rq.
如何检查消息队列是否已存在?
我有2个不同的应用程序,一个创建队列,另一个从该队列读取.
因此,如果我首先运行从队列中读取的客户端,而不是崩溃.
所以为了避免我想首先检查队列是否存在.
这是我如何读取队列的代码片段:
QueueingBasicConsumer <ConsumerName> = new QueueingBasicConsumer(<ChannelName>);
<ChannelName>.BasicConsume("<queuename>", null, <ConsumerName>);
BasicDeliverEventArgs e = (BasicDeliverEventArgs)<ConsumerName>.Queue.Dequeue();
Run Code Online (Sandbox Code Playgroud) 你能推荐用于访问AMQP(RabbitMQ)的Python库吗?从我的研究pika似乎是首选.
有没有简单的方法为Ubuntu安装RabbitMQ?我做了以下事情:
将以下行添加到/etc/apt/sources.list:
deb http://www.rabbitmq.com/debian/ testing main
Run Code Online (Sandbox Code Playgroud)
然后安装apt-get:
$ sudo apt-get install rabbitmq-server
Run Code Online (Sandbox Code Playgroud)
但我每次都会收到以下错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
Since you only requested a single operation it is extremely likely that
the …Run Code Online (Sandbox Code Playgroud) 关于消息代理(例如RabbitMQ和面向消息的中间件)之间的区别,我有点困惑.除了维基百科上的内容之外,我找不到太多信息.在搜索MOM时,我在AMQP上找到有关MOM协议的信息.这是什么意思?那妈妈是什么?我也读过RabbitMQ实现了AMPQ协议..为什么这会让RabbitMQ成为一个消息代理?消息代理和MOM是一回事吗?
希望有些人可以解开我的困惑.谢谢