Giter Club home page Giter Club logo

secure_queue's Introduction

secure_queue

一句话,secure_queue可以让redis支持ACK(消息确认), 值得一用,更多的介绍 请点击

很喜欢使用redis做MQ消息队列, 使用他的List类型结构实现队列, 简单高效性能极好的优点, 但是相比rabbitmq、kafka又没有消息确认的特性. 那么我通过实现一个服务来扩展redis的消息确认功能. 已经封装了server及client,很易用.

secure_queue主要分两部分:

  • secure_queue client

每次消费队列的时候,会往该队列的ack_queue有序队列扔任务, score为任务的最长超时时间.

  • secure_queue.py

用来维护ack_queue, 把符合条件的任务重新扔回任务队列

Future:

  1. redis zset的value不能重复,解决方法在value加入uuid.
  2. 加入重试次数控制.

##使用方法:

启动redis

redis-server

启动secure_queue服务端

start_secure_queue.py

secure_queue的客户端测试代码

#coding:utf-8
import random
from mq import MessageQueue

addr = {
    "host":"127.0.0.1",
    "port":6379,
    "queue":'queue', #队列名字
}

def test_timeout():
    r.rpush('[email protected]',timeout=5)

def test_only():
    r.rpush('http://github.com/rfyiamcool')

def test_commit():
    r.rpush('xiaorui.cc',timeout=5)
    r.commit('xiaorui.cc')
    
def test_performance():
    for i in range(10000):
        r.rpush(random.randrange(1,10000),timeout=10)
    
r = MessageQueue(**addr)

if __name__ == "__main__":
    test_only()
    test_commit()
    test_timeout()
    test_performance()
    print 'end...'

##性能测试 secure_queue本身没什么性能损耗,简单的暴力的测试一秒钟可以处理1w+的任务

secure_queue's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.