8. AMQP
• Open standard for messaging middleware
• Vendor neutral
• Wire level protocol
• Mandates interoperatibility
• Abundant number of libraries that speak it
10. AMQP Components
• Broker
• Combination of Exchange and a Queue
• Exchange routes messages (stateless) based
on patterns
• Queue buffers messages (stateful)
• Bound by Bindings
25. Nanite
• Agents register themselves and advertise their
services, constantly pinging the mappers
• Mappers remove timed-out agents
• Work distributed based on agent load
26. Nanite
• Agents can interoperate with each other
during one single message processing
• Mapper state can (and should) be stored in
redis
• Mappers live inside your application or
standalone
27. Intermediate Messages
class Reactor
include Nanite::Actor
expose :react
def react(payload)
request("/worker/work", "kill all humans",
:intermediate_handler => lambda {|res| puts res})
# working, working...
yield "I'm almost done"
# cleanup the mess
"done reacting to message with payload: #{payload}"
end
end
28. Intermediate Messages
class Worker
include Nanite::Actor
expose :work
def work(payload)
Human.all.each do |human|
human.destroy
yield "Destroyed human #{human.name}"
end
"Killed all the humans"
end
end
29. Nanite Internals
• Based on EventMachine and Ruby amqp library
(also EventMachine-based)
• Everything runs in the EventMachine loop
30. Nanite Internals
• Uses a combination of the following queues to
work
• Registration queue
• Heartbeat queue
• Advertise queue
• Agent queues
31. Nanite Internals
• Messages can be encrypted and signed
between agents and mappers
• Sends marshaled Ruby (default),YAML or
JSON
• The code internals are actually mind-boggling