doujiang24 / lua-resty-kafka

Lua kafka client driver for the Openresty based on the cosocket API
BSD 3-Clause "New" or "Revised" License
801 stars 274 forks source link

即使是在异常情况下,为什么producer:send返回的都是true呢 #75

Closed wangzili064 closed 5 years ago

wangzili064 commented 5 years ago

image

wangzili064 commented 5 years ago

local bp = producer:new(broker_list, { producer_type = "async" }) local ok, err = bp:send("jb_unify_log_info", nil, message) ngx.log(ngx.ERR, "kafka send err message---err:", err) ngx.log(ngx.ERR, "kafka send err message---ok:", ok) ngx.log(ngx.ERR, "kafka send err message:", type(ok)) if not ok then ngx.log(ngx.ERR, "kafka send err message:", message) return else

wangzili064 commented 5 years ago

image

xiaooloong commented 5 years ago

producer_type = 'async' 异步发送的原因吧。异步模式发送只是把消息添加到队列就返回成功了。然后定时或者队列满了才批量发送的。那个时候已经脱离了当前的请求了。

wangzili064 commented 5 years ago

producer_type = 'async' 异步发送的原因吧。异步模式发送只是把消息添加到队列就返回成功了。然后定时或者队列满了才批量发送的。那个时候已经脱离了当前的请求了。

嗯,应该是,多谢了

doujiang24 commented 5 years ago

@wangzili064 是的,异步模式下,只有 buffer 满了才会返回错误的 具体原因正如 @xiaooloong 说的那样

wangzili064 commented 5 years ago

@wangzili064 是的,异步模式下,只有 buffer 满了才会返回错误的 具体原因正如 @xiaooloong 说的那样

那怎么设置成同步呢,是不是不支持

doujiang24 commented 5 years ago

@wangzili064 请仔细看文档:https://github.com/doujiang24/lua-resty-kafka#restykafkaproducer,`producer_type`.

wangzili064 commented 5 years ago

@wangzili064 请仔细看文档:https://github.com/doujiang24/lua-resty-kafka#restykafkaproducer,producer_type. sorry,已了解,多谢您

wangzili064 commented 5 years ago

@wangzili064 请仔细看文档:https://github.com/doujiang24/lua-resty-kafka#restykafkaproducer,producer_type. sorry,已了解,多谢您

还是想打扰一下,看了文档,觉得异步的话,我还是没办法获取回调信息呢