A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/leporo/tornado-redis/issues/106 below:

guarantee messages order · Issue #106 · leporo/tornado-redis · GitHub

This repository was archived by the owner on Apr 3, 2019. It is now read-only.

This repository was archived by the owner on Apr 3, 2019. It is now read-only.

guarantee messages order #106

Description

I have a stackoverflow question here.

Is it possible to consume redis messages within same order as they were published? E.g. see code below:

def __init__(self):
    self.async_redis_publisher = tornadoredis.Client(port=TORNADO_REDIS_PORT)
    self.async_redis = tornadoredis.Client(port=TORNADO_REDIS_PORT)

@engine
def listen(self, channels):
    yield Task(self.async_redis.subscribe, channels)
    self.async_redis.listen(self.pub_sub_message)

def pub_sub_message(self, message):
    print(current_time, message)

# code below represents 2 different *web socket messages* within same thread and same insntance of class
def on_ws_message(self): 
   self.async_redis_publisher.publish('1', 'message1') # also prints time to be sure about order
   # some timeout or e.g. another request 
   self.async_redis_publisher.publish('1', 'message2') # also prints time to be sure about order

redis-cli: monitor:

 1514312168.031272 [0 127.0.0.1:53314] "PUBLISH" "1" "message2"
 1514312168.035996 [0 127.0.0.1:53314] "PUBLISH" "1" "message1"

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4