【问题标题】:use qpid-proton to send persistent messages to Azure service bus - url parsing error使用 qpid-proton 将持久消息发送到 Azure 服务总线 - url 解析错误
【发布时间】:2015-11-18 23:54:19
【问题描述】:

我正在尝试使用 python-qpid-proton 0.9.1 版向 Azure 服务总线队列发送消息。

examples/python/messenger/ 中的示例接受 amqps://:@/ 形式的地址,我可以使用它成功地将消息发送到 Azure 上的队列。这样做的问题是我无法控制正在发生的大部分事情,即我无法真正看到发送是否失败。最后,我想保留这些消息,以防互联网连接暂时中断。

示例代码 examples/python/db_send.py 和 examples/python/simple_send.py 似乎在这方面更有用,因为它们使用 MessagingHandler 而不是 Messenger 类。但是当我运行它们时,我得到了这个错误:

 ./simple_send.py -a amqps://send:mxirestofmypassword@testsoton.servicebus.windows.net/queue2
Traceback (most recent call last):
 File "./simple_send.py", line 62, in <module>
    Container(Send(opts.address, opts.messages)).run()
  File "/usr/local/lib/python2.7/dist-packages/proton/reactor.py", line 120, in run
    while self.process(): pass
  File "/usr/local/lib/python2.7/dist-packages/proton/reactor.py", line 143, in proce
    self._check_errors()
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3737, in dis
    ev.dispatch(self.handler)
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3662, in dis
    result = dispatch(handler, type.method, self)
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3551, in dis
    return m(*args)
  File "/usr/local/lib/python2.7/dist-packages/proton/handlers.py", line 416, in on_r
    self.on_start(event)
  File "./simple_send.py", line 36, in on_start
    event.container.create_sender(self.url)
  File "/usr/local/lib/python2.7/dist-packages/proton/reactor.py", line 671, in creat
    session = self._get_session(context)
  File "/usr/local/lib/python2.7/dist-packages/proton/reactor.py", line 634, in _get_
    return self._get_session(self.connect(url=context))
  File "/usr/local/lib/python2.7/dist-packages/proton/reactor.py", line 611, in conne
    if url: connector.address = Urls([url])
  File "/usr/local/lib/python2.7/dist-packages/proton/reactor.py", line 555, in __ini
    self.values = [Url(v) for v in values]
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3851, in __i
    if defaults: self.defaults()
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3894, in def
    self.port = self.port or self.Port(self.scheme)
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3868, in _ge
    return portstr and Url.Port(portstr)
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3812, in __n
    port = super(Url.Port, cls).__new__(cls, cls._port_int(value))
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3833, in _po
    raise ValueError("Not a valid port number or service name: '%s'" % value)
ValueError: Not a valid port number or service name: 'mxitheresto'

在我看来,它无法正确解析地址。我粘贴了与以前相同的地址。我也把它粘贴到python解释器中,像这样:

 import proto
 u =     proton.Url("amqps://send:mxirestofmypassword@testsoton.servicebus.windows.net/queue2")
 # no error, and I can access all the parameters:
 u.port
 5671
 u.username
 send
 # ...

如果我使用没有用户名和密码的本地连接,它可以正常工作。如果我不使用任何用户名和密码但显然无法通过身份验证,则可以通过这一点。

有什么方法可以使用 MessagingHandler 类并指定用户名和密码以将消息发送到远程(如在 Azure 上)?

【问题讨论】:

标签: queue persistent qpid broker


【解决方案1】:

examples/python/db_send.py 和examples/python/simple_send.py 请求Azure Service Bus 是OK 的,但是他们无法建立与AMQPS 方案的sender 连接。

参考MSDN官方文档https://msdn.microsoft.com/en-us/library/azure/jj841070.aspx,MS推荐使用Messenger Class发送消息。

您的问题的详细信息,请参阅我在python-qpid-proton examples, send message to azure not working的帖子。

【讨论】:

    猜你喜欢
    • 2015-11-18
    • 2018-01-16
    • 2017-03-09
    • 2021-09-09
    • 1970-01-01
    • 2018-01-19
    • 2014-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多