最近项目需要用到ActiveMQ,使用topic接收消息,网上搜到的例子,发送都没有问题,把conn.start()函数注释掉就ok了,但是接收消息的函数总是报message不存在。
notify_func(frame)
TypeError: on_message() missing 1 required positional argument: 'message'
经过检查发现新版本的stomp函数on_message()变了,由之前的3个参数变成了2个参数。
修改代码就能够正常接收了,代码如下:
def on_message(self, frame):
print(f"message: headers:{frame.headers['destination']}, message:{frame.body}")