diff --git a/platypush/backend/redis.py b/platypush/backend/redis.py index 79c5bb31..2b8cb0ae 100644 --- a/platypush/backend/redis.py +++ b/platypush/backend/redis.py @@ -42,8 +42,15 @@ class RedisBackend(Backend): while not self.should_stop(): try: - msg = self.redis.blpop(self.queue) - msg = Message.build(json.loads(msg[1].decode('utf-8'))) + msg = self.redis.blpop(self.queue)[1].decode('utf-8') + + try: + msg = Message.build(json.loads(msg)) + except: + import ast + msg = Message.build(ast.literal_eval(msg)) + + logging.info('Received message on the Redis backend: {}'.format(msg)) self.bus.post(msg) except Exception as e: logging.exception(e) diff --git a/platypush/plugins/redis.py b/platypush/plugins/redis.py new file mode 100644 index 00000000..466b5131 --- /dev/null +++ b/platypush/plugins/redis.py @@ -0,0 +1,17 @@ +import logging + +from redis import Redis + +from platypush.message.response import Response +from platypush.plugins import Plugin + + +class RedisPlugin(Plugin): + def send_message(self, queue, msg, *args, **kwargs): + redis = Redis(*args, **kwargs) + redis.rpush(queue, msg) + return Response(output={'state': 'ok'}) + + +# vim:sw=4:ts=4:et: +