当我nack发布/订阅邮件时,将不会重新发送它

问题描述

似乎当我取消发布/订阅消息(message.nack())时,发布/订阅 转储邮件,从不重试再次发送。我也不 在Google的订阅控制台中看到未确认的消息 云。如果我不确认该消息,则发布/订阅会发布 邮件在一段时间后重新发送(使用 讯息:丢弃1个项目,因为它们的租期太长。

Service是我自己的类,如果可以,它将返回消息 发布,如果不相关,则返回“确认”(确认 而不发布它)或取消确认(如果尚未提供该服务) 准备发布它。

我正在使用以下软件包:google-api-core == 1.16.0 google-cloud-pubsub == 1.5.0 Flask == 1.1.2

整个服务在kubernetes集群上使用flask运行。

subscriber = pubsub_v1.SubscriberClient(credentials=credentials)
subscription_path = subscriber.subscription_path(project_id,subscription_name)
def callback(message):
    enriched_message = Service.enrich(promo,message.data,0)

    # Ckeck if a message has to be published to the topic or not.
    if enriched_message == 'ackNowledge':
        message.ack()
    elif enriched_message == 0:
        message.nack()
    elif enriched_message != 0:
        answer = CrmPosService.pub(enriched_message)
        if answer == 'ackNowledge':
            message.ack()

try:
    future = subscriber.subscribe(subscription_path,callback=callback)
    # Keep the main thread from exiting so the subscriber can
    # process messages in the background.
    while True:
        time.sleep(1)
except Exception as ex:
    logger.error('Could not subscribe')
    logger.error(ex,exc_info=True)
    raise ex

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)