FMQ

Get Version

0.3.5

→ ‘Free Message Queue’

What

The project implements a queue system with a server and some client apis.

The server is a rack server that holds REST-named queues, so that the implementation can be changed rapidly. You can GET, POST, DELETE, HEAD queue messages using the normal HTTP requests. The system itself uses a configuration file (config.ru) to setup queues at startup or even at runtime. The queue implementations can be changed or you can develop own queues with ease.

For an simple administration try out the integrated ajax based web interface.

The client apis are implemented using the HTTP protocol, so that you can use even curl to receive messages. A client library for ruby is implemented right now, other languages will follow.

The queue itself is a RESTful url like http://localhost:5884/myQueueName/ or http://localhost:5884/myApplication/myQueueName/. If you do a GET request to this url with a web browser you will receive one message from the queue.

If you need some help in getting thinks running watch the screencasts.

Features

Installing

sudo gem install fmq

First steps

After installing the gem you can start by creating a project:

fmq create my_project_name

next step is to change to the folder and start the FMQ server:

cd my_project_name
rackup -p 5884

The server will start and host a admin interface on http://localhost:5884/admin/index.html.

Have a look at rDoc to see how to use the client API and the queue configuration on the server.

Configuration

If you have created your FMQ project you will find a config.ru file, that contains the configuration. But you can customize it in any way you like. Here is an example for a very basic setup:

require "fmq"

queue_manager = FreeMessageQueue::QueueManager.new() do
  setup_queue "/mail_box/your_name" do |q|
    q.max_messages = 10000
    q.max_size = 10.mb
  end
end

run FreeMessageQueue::Server.new(queue_manager)

Creating your own queues

You can easyly implement your own queues by extending the BaseQueue class:

class MyTestQueue < FreeMessageQueue::BaseQueue
  def put(message)
    puts "INCOMMING: #{message.payload}"
  end
  
  def poll
    FreeMessageQueue::Message.new "Hello World", "text/plain" do |m|
      m.option["Time"] = Time.now
    end
  end
end

Ok, so if you have special needs or need a queue that processes a message in different ways it is easy to do…

Queues that ship with FMQ

FilePersistentQueueRoundRobinQueueForwardQueueSynchronizedQueueFileQueue

Git, patches, forks and all that stuff

If you want to clone the git repository use the command below. Patches, forks and feature requests are welcome, please send them to fmq-3z (at) gmx.net.

git clone git://github.com/threez/fmq.git

or if you are behind a http proxy

git clone http://github.com/threez/fmq.git

Build and test instructions

after cloning the repository you can

cd fmq

to the directory. But in order to run the tests you have to start a FMQ server first:

cd default-server
rackup -p 5884

then run the tests

rake test

Loadtest

To check the performance we have done a load test. The system under test was a 2 GB dual-core intel 1.8 Ghz with 100 Mbit/s LAN and Ruby 1.8.6.
In the test we simulate 20 applications (with 20 threads). Each of this applications did 2 POSTs and 1 GET request for 30min. The POST requests where about 1KB.

This are the results (from 2008-06-10; Mongrel):

Test duration: 30:01 min
Average response time: 36 ms
Passed Transactions: 862203
Failed (because of connection timeout): 285
Transactions per second: 476,1
Transactions per minute: 28.749,60
Transactions per hour: 1.724.976

License

This code is free to use under the terms of the GNU GENERAL PUBLIC license (v3).

Vincent Landgraf, 25th July 2009
Theme extended from Paul Battley