Qup-1.2.0 - API for Message Queue and Pub/Sub messaging

I’d like to announce the first public release of qup, generalized API
for
Message Queue and Publish/Subscribe messaging patterns with the ability
to plug
in an appropriate messaging infrastructure based upon your needs.

Qup ships with support for Kestrel, Redis, and a filesystem
infrastructure
based on Maildir. Additional Adapters will be developed as needs arise.
Please
submit an Issue (Issues · copiousfreetime/qup · GitHub) to have
a new
Adapter created. Pull requests gladly accepted. Instructions on how to
write an
Adapter are provided:

 https://github.com/copiousfreetime/qup/blob/master/ADAPTER_API.rdoc

== FEATURES

Qup provides an abstract implementation of two common messaging
patterns.

  1. Basic Message Queue

Examples of the basic message queue concept are:

* Work/Task Queues - 

http://www.rabbitmq.com/tutorials/tutorial-two-python.html
* JMS Queue -
http://docs.oracle.com/javaee/6/api/javax/jms/Queue.html
* Amazon SQS - Fully Managed Message Queuing – Amazon Simple Queue Service – Amazon Web Services

This is a pattern where one or more Producers puts Messages on a Queue
and
one or more Consumers received those Messages. Each Message is
delivered only 1
time to a Consumer.

  1. Publish/Subscribe

Publish–subscribe pattern - Wikipedia

Qup implements a Topic based system, where Publishers send Messages on
a Topic
and all Subscribers to that topic each receive their own copy of the
message.

Qup assumes that the messaging systems it has adapters for provided
durable and
acknowledgeable messaging.

[Durability]

When message is sent to the messaging system by Qup, the message is
persisted to
disk.

[Acknowledgeable Messages]

When a Consumer receives a Message, and then processes it, Qup assumes
that
the messaging infrastructure requires that the Message be positively
acknowledged. In other words, if the Consumer does not acknowledge the
message
then the messages infrastructure will put the Message back onto the
Queue.

=== Basic Message Queue

session = Qup::Session.new( “maildir:///tmp/test-queue” )
queue = session.queue( ‘basic-messaging’ )
producer = queue.producer

consumer_1 = queue.consumer
consumer_2 = queue.consumer

producer.produce( ‘message_1’ )
producer.produce( ‘message_2’ )

message_1 = consumer_1.consume
puts message_1.data # => ‘message_1’
consumer_1.acknowledge( message_1 )

consumer_2.consume do |message_2|
puts message_2.data # => ‘message_2’
end # auto acknowledged at the end of the block

=== Publish/Subscribe

session = Qup::Session.new( “kestrel://messaging.example.com:22133”
)
topic = session.topic( ‘topic-messaging’ )
publisher = topic.publisher

subscribers = []
3.times do |n|
subscribers << topic.subscriber( “subscriber-#{n}” )
end

publisher.publish( ‘a fine message on a topic’ )

subscribers.each do |sub|
sub.consume do |msg|
puts msg.data # => ‘a fine message on a topic’
end # auto acknowledge an end of block
end