Skip to content

Thrift RPC over an AMQP compliant queue in Ruby

Notifications You must be signed in to change notification settings

rjharmon/toamqp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thrift over AMQP (toamqp)

DESCRIPTION

Transports thrift messages via an AMQP broker.

Advantages: (see also)

  • Less Network Load You don’t open as many TCP connections (one instead of one per service)
  • Simplicity One well known service point (your broker) instead of many IP/port pairs to know for clients
  • Persistence Messages wont get lost if you don’t want them to.
  • Safe IPC Since the AMQP broker implements a queue, you can avoid doing so on your end. No mucking around with Threads and Queues.

This library provides the glue code between thrift and bunny (AMQP client) and allows easy creation of a service.

SYNOPSIS

Using the following interface definition:


  service AwesomeService {
    // a little hommage 
    oneway void battleCry(1:string battlecry);
  }

Create a connection to your AMQP server:


  # Default is localhost, user guest, password guest. 
  TOAMQP.connection_manager.connection_attributes = {
    :host => 'mq.mydomain.com
  }

On the server (consumer of messages):


  class MyAwesomeService < TOAMQP::Service::Base
    exchange 'awesome_service'    # public name of the service
    serves AwesomeService         # Module generated by thrift
    
    def battleCry(message)
      puts messages
    end
  end
  
  TOAMQP.server(MyAwesomeService.new).serve--

On the client:


  client = TOAMQP.client('awesome_service', AwesomeService)
  
  client.battleCry('chunky bacon!')   # prints 'chunky bacon!' on the server

INSTALLATION

A development machine needs a fairly recent AMQP broker (should implement the headers binding type) and the full thrift install. You need the full install to be able to compile thrift service definitions.

To install this library, just type


  $ gem install toamqp

SPECIFICATION

To run the specs, just type


  $ rake specs

Integration tests need a AMQP broker to run on localhost. This has so far only been tested with RabbitMQ. (http://www.rabbitmq.com/)


  $ rake thrift
  $ rake

FEEDBACK

Issue tracker at: http://www.github.com/kschiess/toamqp

LICENSE

(The MIT License)

Copyright © 2009,2010 Kaspar Schiess

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Thrift RPC over an AMQP compliant queue in Ruby

Resources

Stars

Watchers

Forks

Packages

No packages published