【发布时间】:2020-04-07 12:56:04
【问题描述】:
我正在用 python 编写一个 azure 函数。收到消息后,我将转发 n 条消息。
我的代码是:
def sendToQueue(data):
logging.info('sendToQueue: %s', data)
msg = Message(encodeData(data))
d = json.loads(data)
batchId = d['BatchId']
logging.info('sending message with batch Id: %s', batchId)
try:
logging.info('Sending oos message to queue %s', queue_oos_mssql_inbox)
sbs.send_queue_message(queue_oos_mssql_inbox, msg)
logging.info('Done Sending oos message to queue %s', queue_oos_mssql_inbox)
except :
logging.error('Unable to process message %s', batchId)
errorDescription = 'Unable to sent message to ' + queue_oos_mssql_inbox
logging.error('errorDescription message %s', errorDescription)
error = createErrorMessage(batchId, '404', str(errorDescription))
logging.error('error message %s', error)
sendToErrorQueue(json.loads(error))
logging.debug('done sending message: ')
当它无法发送消息时,我想记录错误。我该如何做这样的事情:'除了 pyodbc.Error as ex:',但随后使用 ServiceBus.error?
我找不到任何示例或文档。
【问题讨论】:
标签: python-3.x azure azure-functions azureservicebus