Skip to content

Framework to implement servies based on AMQP inspired by Sinatra web framework

Notifications You must be signed in to change notification settings

mlankenau/qnatra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Qnatra

About

Qnatra provides a very thin layer above an amqp client library (bunny). It let you as a developer focus on the handling of messages received from the queue and don't have to worry about how to access the queue and handle threading.

How to use

Example

class Processor <  Qnatra::Processor


  system_event do |status, message|
    puts "System #{status}: #{message}"
  end

  error do |args|
    puts "Error #{args[:error]} for message: #{args[:msg][:payload]}" 
  end

  success do |args|
    puts "we processed a message from #{args[:queue]} and routing key #{args[:msg][:delivery_details=][:routing_key]}")
  end


  # define an outbound exchange (an exchange we want to send messages to)
  outbound :send_mail,  :exchange => "some_other_exchange"


  # define an exchange and a queue we receive from
  process :exchange => "my_exchange", :queue => "my_queue", :key=>"a_routeing_key" do |msg|
    msg_text = msg[:payload]
    puts "processing message......"
    # todo: implement processing :)

    post(:send_mail, "Some message", :key => 'some_routing_key')
  end

end

settings = { :hosts => ['host1', 'host2', 'hostx'] }
Processor.start settings

About

Framework to implement servies based on AMQP inspired by Sinatra web framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages