Use pop for checking messages with websocket
I1c94ad82c3b20cc331045c19d4a9987a701b081b fixed the issue in Zaqar where the pop argument was wrongly named. We can now use it in the zaqar collector to retrieve messages over websocket. Change-Id: I0ce894b0eef7018a37db9ef9d1b43d8d20629bf0
This commit is contained in:
parent
cb846967f7
commit
432abd47ec
@ -90,27 +90,19 @@ class Collector(object):
|
|||||||
'ttl': 10000})
|
'ttl': 10000})
|
||||||
ws.send(req)
|
ws.send(req)
|
||||||
|
|
||||||
# TODO(dprince) would be nice to use message_delete_many but
|
# check for pre-existing messages
|
||||||
# websockets doesn't support parameters so we can't send 'pop'.
|
req = self._create_req(endpoint, 'message_delete_many',
|
||||||
# This would allow us to avoid the 'message_delete' below. Example:
|
|
||||||
# req = self._create_req(endpoint, 'message_delete_many',
|
|
||||||
# {'queue_name': CONF.zaqar.queue_id, 'pop': 1})
|
|
||||||
req = self._create_req(endpoint, 'message_list',
|
|
||||||
{'queue_name': CONF.zaqar.queue_id,
|
{'queue_name': CONF.zaqar.queue_id,
|
||||||
'echo': True})
|
'pop': 1})
|
||||||
resp = ws.send(req)
|
resp = ws.send(req)
|
||||||
messages = json.loads(resp.content).get('messages', [])
|
messages = json.loads(resp.content).get('messages', [])
|
||||||
|
|
||||||
if len(messages) > 0:
|
if len(messages) > 0:
|
||||||
# NOTE(dprince) In this case we are checking for queue
|
# NOTE(dprince) In this case we are checking for queue
|
||||||
# messages that arrived before we subscribed.
|
# messages that arrived before we subscribed.
|
||||||
logger.debug('Websocket message_list found...')
|
logger.debug('Websocket message found...')
|
||||||
msg_0 = messages[0]
|
msg_0 = messages[0]
|
||||||
data = msg_0['body']
|
data = msg_0['body']
|
||||||
req = self._create_req(endpoint, 'message_delete',
|
|
||||||
{'queue_name': CONF.zaqar.queue_id,
|
|
||||||
'message_id': msg_0['id']})
|
|
||||||
ws.send(req)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# NOTE(dprince) This will block until there is data available
|
# NOTE(dprince) This will block until there is data available
|
||||||
|
Loading…
Reference in New Issue
Block a user