views:

25

answers:

1

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: alt text (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.

A: 

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.

T.K.