Actor system with amqp or in memory queues as backend. Provides an easy to use DSL and a high level abstraction to the AMQP protocol.
class MyActor < AmqpActors::Actor
act do |msg|
puts msg
end
end
AmqpActors.Sytem.start
MyActor.push 'hello'Act (required). Message processor
act do |msg|
...
endTyped messages. Built in type checking of messages.
message_type Numeric
message_type Array => String
message_type Set => ObjectConcurrency. Define number of threads for an actor.
thread_count 10Helpers. Define helper methods for your actor.
helpers do
def do_stuff
...
end
endInbox size. Check number of enqueued messages.
inbox_size # => 0Destory actor. Closes inbox and kills all actor threads for current actor.
dieMessages are sent by using an actors class method push
Start. Start the actor system.
AmqpActors.System.startStop. Stops the system.
AmqpActors.System.stopSubclass AmqpActors::TestActor in tests. It uses an in memory queue as backed by default and provides an extra method for passing values out of the actor. This can then be read syncronously in the test.
class TestActor < AmqpActors::TestActor
act do |msg|
output msg + 1
end
end
..
TestActor.push 0
TestActor.output # => 1