什么
我正在使用 4 个消费者从 NSQ 服务器消费消息。我正在尝试调试我看到backing off
日志的原因,因为我的消费者在发生这种情况时会放慢速度。
我正在记录异常,那是我返回 aFalse
以重新排队消息的时候。我没有看到任何异常被记录,但我一直看到这条消息。帮助!!
2013-07-30 14:41:10,304 INFO [ip-10-114-195-89:4150:nsq_msg_handler] backing off for 3.58 seconds
2013-07-30 14:41:10,304 DEBUG took 0.000000 seconds for json_data _id: 52d730669c615b67
2013-07-30 14:46:44,414 INFO [ip-10-114-195-89:4150:nsq_msg_handler] backing off for 3.58 seconds
2013-07-30 14:46:44,414 DEBUG took 0.000000 seconds for json_data _id: 7e9c5fe5ba168496
代码
def connect_nsq(self):
r = nsq.Reader(message_handler=self.nsq_msg_handler, lookupd_http_addresses=["127.0.0.1:4161"], topic="test_topic", channel="test_channel", max_in_flight=500)
nsq.run()
# callback
def nsq_msg_handler(self, message):
try:
before_ts = get_utc_now_ts()
json_data = json.loads(message.body)
my_data = json_data["key1"]
my_data = json_data["key2"]
my_data = json_data["key3"]
after_ts = get_utc_now_ts()
delta = after_ts - before_ts
logger.debug("took %f seconds for json_data _id: %s" % (delta, json_data["_id"]))
except Exception as reason:
print reason, traceback.format_exc()
return False
return true