Skip to content

Tornado/RabbitMQ socket server/library for message forwarding

Notifications You must be signed in to change notification settings

vis-netlausnir/hermodur

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hermodur

Introduction

AMQP/WebSocket handler for Tornado web server. The purpose of Hermodur is to forward messages from an AMQP server to a client connected to the Tornado server via a socket.io server. The main benefits of this are two:

  • Only one connection is opened to the AMQP server (a single instance of RabbitMQ supports rougly 800)
  • Since the listener is a socket.io server it enables older browsers that do not have WebSocket implemented to connect.

Installation

There are two ways to install hermodur onto your system

# old school - setup tools
python setup.py

# new way - using pip
pip install http://github.com/vis-netlausnir/hermodur/tarball/master

How to use

In order to load the HermodurConnection into the Tornado ioloop it has to be configured and the connection the AMQP server has to be initiated. Below is a small example

from tornado import web

from tornadio2 import TornadioRouter, SocketServer
from hermodur import HermodurConnection


class SocketIOHandler(web.RequestHandler):
    def get(self):
        self.render('../socket.io.js')

# We use the defaults localhost:5672 and guest:guest on vhost '/'
HermodurConnection.setup_connection()

# Use the routes classmethod to build the correct resource
HermodurRouter = TornadioRouter(HermodurConnection)

# configure the Tornado application
application = web.Application(
    HermodurRouter.urls,
	socket_io_port = 8001
)

if __name__ == '__main__':
	import logging
	logging.getLogger().setLevel(logging.DEBUG)

	# Create and start tornadio server
	SocketServer(application)

The client then connects using a socket.io client and a connection method supported by the client's browser. When the connection to the server is established the client simply send a JSON message containing the desired exchange and routing_key.

{ "exchange": "my_exchange", "routing_key": "my_routing_key" }

A more detailed example will be added soon ...

About

Tornado/RabbitMQ socket server/library for message forwarding

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages