Giter Club home page Giter Club logo

memqueue's Introduction

memqueue

Introduction

memqueue is an in-memory queue server. Its goal is to share messages across multiple consumers polling from the same queue where each consumer can consume at their own pace without missing messages. This is made possible by using message expiry and queue revisions.

memqueue queues get a new revision each time a message is inserted. Consumers can specify which revision they want to poll from, allowing them to consume messages that have already been consumed but are not expired yet.

Example

A good example that illustrates memqueue's features is a group chat server over HTTP. We'll create a single queue for the group. Each user will poll from this queue waiting for new messages and when a new message arrives, the queue revision is bumped by one and the message get sent to all consumers along with the latest revision. During the time a consumer is consuming a message and reconnecting, new messages can come in and the queue revision can be bumped by few digits. This is not an issue because the next time each of the consumers connect, they'll provide the revision they are at and the poll will retrieve all the messages they have missed after this revision.

memqueue REST API

memqueue has an HTTP REST interface and runs its own HTTP server built on top of lthread. Websocket support is on the TODO list.

###Create a new queue in memory

PUT /<queue_name>

parameters

expiry: Integer (ms). (Optional)

Milliseconds of queue inactivity before it get's removed. Queue activity can be either queue polling or posting a new message.

max_size: Integer. (Optional)

Number of messages a queue will hold before it either starts dropping messages from head or rejects messages depending on the parameter drop_from_head.

drop_from_head: Boolean (0 or 1). (Optional)

if max_size is specified, and the queue is full, this parameter specifies whether to drop a message from head and insert a new one at tail or reject the message.

consumer_expiry: Integer (ms). (optional)

If set, consumers can specify their <consumer_id> when polling to inform other consumers that <consumer_id> started polling. memqueue only inform other consumers about new consumers. A consumer is considered new if he hasn't been seen polling in the last consumer_expiry period.

###Post a message to <queue_name>

POST /<queue_name>

Parameters

expiry: Integer (ms). (optional)

Message data must be included in the HTTP POST body

###Poll messages from <queue_name>

GET /<queue_name>

Parameters

rev: Integer. (optional)

timeout: Integer (ms). (optional)

latest: Boolean(0 or 1). (optional)

consumer_id: String. (optional)

include_consumers: Boolean(0 or 1). (Optional)

###Poll from multiple queues

GET /mpoll

Parameters

Takes the same parameters as GET / <queue_name> with a -<n> appended to the parameter where <n> is an integer grouping each of the queue parameters.

total_queues: Integer. (required)

Specifies the total number of queues you are polling from.

###Delete queue <queue_name>

DELETE /<queue_name>

memqueue's People

Contributors

halayli avatar

Watchers

James Cloos avatar Aleph Archives avatar

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.