开发者

stomp.py based durable client fills up subscribers list in ActiveMQ

开发者 https://www.devze.com 2023-01-17 01:07 出处:网络
I have a problem with a durable client on ActiveMQ. I amusing stomp.py in Python. conn.start() conn.connect(wait=True, header = {\'client-id\': \'myhostname\' })

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:

stomp.py based durable client fills up subscribers list in ActiveMQ

(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 workin开发者_如何学Cg somehow.


I solved it, the whole thing was due to a simple spelling mistake. The line:

conn.connect(wait=True, header = {'client-id': 'myhostname' })

Should contain 'headers' in plural form.

0

精彩评论

暂无评论...
验证码 换一张
取 消