将消息放入天蓝色队列 [英] Putting message into azure queue

查看:55
本文介绍了将消息放入天蓝色队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循从 Azure Python SDK .当我尝试将消息放入队列时,

I follow the details given for putting the message into an azure queue from Azure Python SDK. When I try to put a message into queue,

from azure.storage import QueueService
queue_service = QueueService(account_name, account_key)
queue_service.put_message('taskqueue', 'Hello world!')

消息放入队列中,但为空.任何帮助将不胜感激.

a message is put in the queue but it is empty. Any help will be appreciated.

推荐答案

此处的问题是编码格式.python的默认编码格式是"ASCII",而消息在放入队列之前需要以base-64格式编码.以下代码完成了工作.

The problem here is encoding format. The default encoding format of python is "ASCII", whereas the message needs to be encoded in base-64 format before putting into queue. The following code did the work.

from azure.storage import QueueService
import base64
queue_service = QueueService(account_name, account_key)
queue_service.put_message('taskqueue', base64.b64encode('Hello world!'))

这篇关于将消息放入天蓝色队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆