Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Intro to MQ

1,349 views

Published on

Slides from an intro to MQ talk I gave at a Toronto Ruby Brigade meet up.

Published in: Technology

Intro to MQ

  1. 1. Intro to Message Queues<br />Rob Paulsen@RobWasHererob.paulsen @ gmail.com<br />
  2. 2. “message queues”<br />
  3. 3. why, what, how<br />
  4. 4. AMQP<br />
  5. 5. gem 'amqp'<br />
  6. 6. why<br />
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
  13. 13.
  14. 14.
  15. 15.
  16. 16.
  17. 17.
  18. 18. require 'amqp'<br />def publish(order)<br />json_order = serialize_to_json(order)<br />AMQP.start(:host => SERVER_IP) do<br />MQ.queue('PrintQueue').publish(json_order)<br /> end<br />end<br />
  19. 19. require 'amqp'<br />def subscribe(&msg_callback)<br />AMQP.start(:host => SERVER_IP) do<br />MQ.queue('PrintQueue').subscribe(:ack => true) do |headers, payload|<br /> order = deserialize_from_json(payload)<br />headers.ack<br />msg_callback.call(order)<br /> end<br /> end<br />end<br />
  20. 20.
  21. 21.
  22. 22.
  23. 23.
  24. 24.
  25. 25.
  26. 26.
  27. 27.
  28. 28.
  29. 29.
  30. 30.
  31. 31.
  32. 32. def subscribe(&msg_callback)<br />AMQP.start(:host => SERVER_IP) do<br /> exchange = amq.fanout('OrderExchange')<br />MQ.queue('Terminal123', :exclusive => true)<br /> .bind(exchange).subscribe do |headers, payload|<br /> order = deserialize_from_json(payload)<br />headers.ack<br />msg_callback.call(order)<br /> end<br /> end<br />end<br />
  33. 33.
  34. 34. MQ Server Options <br />RabbitMQ<br />OpenAMQ<br />Apache Qpid / Redhat MRG<br />MSMQ (Microsoft)<br />JMS (Java)<br />WebSphere MQ (IBM)<br />
  35. 35. Notable Gems<br />amqp (asynchronous AMQP)<br />Bunny (synchronous AMQP)<br />Qusion (AMQP for Rails Apps)<br />lots more .. http://rubygems.org/search?query=amqp<br />
  36. 36. Questions?<br />(feel free to throw tomatoes now if you have to)<br />

×