基于 stomp.py 的持久客户端填充 ActiveMQ 中的订阅者列表
我对 ActiveMQ 上的持久客户端有疑问。我在Python中使用stomp.py。
conn.start()
conn.connect(wait=True, header = {'client-id': 'myhostname' })
conn.subscribe(
'/topic/testTopic', ack='auto',
headers = {
'activemq.subscriptionName': 'myhostname',
'selector': "clientid <> '%s'" % 'myhostname'
}
)
正如您从我的代码中看到的,我将 clientId 设置为我自己的主机名。如所附屏幕截图(如下)所示,clientId 显示为“ID:Atlas...”之类的内容。
问题是,每次我断开基于 stomp.py 的客户端时,下次再次连接时都会得到一个新的“clientId”。这会导致 ActiveMQ 中的订阅者列表填满: (上图显示了我的 ActiveMQ 代理上的订阅者。下次我断开连接然后连接时,上面的条目仍将保留,并且将添加另一个条目。很快列表中就会有许多订阅者)。
奇怪的是,选择器 100% 工作(我通过将 <> 更改为 = 来验证这一点,以便消息返回给我),因此 clientId 必须以某种方式工作。
I have a problem with a durable client on ActiveMQ. I am using stomp.py in Python.
conn.start()
conn.connect(wait=True, header = {'client-id': 'myhostname' })
conn.subscribe(
'/topic/testTopic', ack='auto',
headers = {
'activemq.subscriptionName': 'myhostname',
'selector': "clientid <> '%s'" % 'myhostname'
}
)
As you can see from my code, I am setting my clientId to be my own hostname. As shown in the attached screenshot (below), the clientId is shown to be something like "ID:Atlas....".
The problem is that every time I disconnect my stomp.py-based client, I get a new "clientId" the next time I connect again. That causes the list of subscribers in ActiveMQ to fill up:
(The image above shows a subscriber on my ActiveMQ broker. Next time I disconnect and then connect, the entry above will still remain, and another one will be added. Pretty soon I have many subscribers in the list).
The strange thing is that the selector works 100% (I verify that by changing <> to be =, so that the messages come back to me), so the clientId must be working somehow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了,整件事都是由于一个简单的拼写错误造成的。该行:
应包含复数形式的“标题”。
I solved it, the whole thing was due to a simple spelling mistake. The line:
Should contain 'headers' in plural form.