【问题标题】:How to read a queue from ActiveMQ in Python?如何在 Python 中从 ActiveMQ 读取队列?
【发布时间】:2021-07-17 06:39:55
【问题描述】:

我试图从队列中返回数据

import stomp
conn = stomp.Connection([('Host','port')])
conn.connect(wait = True)-
print(conn.subscribe('test_queue', headers={}))

但我得到了错误

----> 3 print(conn.subscribe('test_queue', headers={}))
TypeError: subscribe() missing 1 required positional argument: 'id'

【问题讨论】:

  • 有错误信息清楚地表明问题所在。

标签: python-3.x activemq


【解决方案1】:

错误提示id 参数丢失。

document,你可以找到信息。

id (str) – 唯一标识订阅的标识符

您可以将例如123 设置为唯一ID,并在取消订阅时使用该ID。

from stomp import *
c = Connection([('127.0.0.1', 62613)])
....
c.subscribe('/queue/test', 123)
c.unsubscribe(123)

【讨论】:

    猜你喜欢
    • 2019-02-08
    • 1970-01-01
    • 2018-09-23
    • 2021-03-25
    • 2021-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-04
    相关资源
    最近更新 更多