【发布时间】:2019-11-08 03:47:14
【问题描述】:
我正在使用azure-storage 节点模块。
我想在我的队列上发送 JSON 并在 azure 函数上将其放入我的队列中。
我在队列中发送消息。我将我的消息串起来放入队列中。
// This is my service who send message to queue via node lib azure-storage
const queueMsg = {
userId,
token: tokenNotif
};
queueSvc.createMessage(Config.REGISTRATION_FCM_PUSH_NOTIFICATION_QUEUE, JSON.stringify(queueMsg), (err) => {
if (!error) {
this._logger.info(`User ${userId} has register this push notification token`);
resolve(true);
} else {
reject(false);
}
});
在队列函数中我有一个错误,因为函数认为不是字符串并将消息文本推送到 xx-queue-poison
{"userId":"a6c8a103-dacc-4b15-bffd-60693105f131","token":"xxxx"}
不知道为什么引号被队列中的ASCII码代替了?
我已经测试了其他东西! 从我的服务中,我调用了一个 Http Azure 函数,这个函数调用了队列存储,它是通过这种方式工作的:s ..
HttpTrigger函数调用队列
context.bindings.notificationQueue = [{ userId: name, token }];
并排队接收到的数据
context.log(`Received userId ${queueItem.userId} :: ${queueItem.token}`);
为什么通过使用 HttpTrigger 函数到 QueueTrigger 函数它正在工作,但是当我使用 lib“azure-storage”时不起作用?
谢谢
【问题讨论】:
-
我找到了!我没有将对象字符串化,而是将其转换为 b64。
Buffer.from(JSON.stringify(queueMsg)).toString('base64')它正在工作
标签: node.js azure azure-functions