例如,我通过发出以下命令向NSQ发送消息:
curl -d "test2" http://127.0.0.1:4151/pub?topic=hello
我发现,如果消息处理程序的执行时间超过100秒,它将抛出,并且此消息将超时。在
^{pr2}$如何避免超时?在
这是我的代码:
def process_message(message):
print(message)
time.sleep(100)
message.touch()
return True
r_check = nsq.Reader(
message_handler=process_message,
nsqd_tcp_addresses=['127.0.0.1:4150'],
topic='hello', channel='channel',
lookupd_poll_interval=15,
lookupd_connect_timeout=100000,
lookupd_request_timeout=100000,
max_tries=10
)
nsq.run()
谢谢。在
您应该在处理消息之前调用
message.touch()
,以便告诉NSQD您需要更多的时间来处理该消息。在NSQD中有两个参数控制消息超时:max-msg-timeout and msg-timeout。在
Matt Reiferson解释了它们是如何工作的。在
相关问题 更多 >
编程相关推荐