WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and...

68
WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling

Transcript of WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and...

Page 1: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling

Page 2: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Noah’s Background

¤ Film ¤ Commercial Data Center

Automation Software ¤ Los Angeles, Atlanta, New

Zealand, San Francisco ¤  I like programming in ANY

language that is innovative

Page 3: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

How & Why

¤ Why AMQP? ¤ Why Erlang? ¤ Why OTP? ¤ Why RabbitMQ? ¤ How – Machinery

Page 4: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Why AMQP

¤  Industry Message Standard ¤ Cisco, Microsoft, Red Hat,

VMWare, JPMorgan, Chase, Goldman Sachs

¤ Binary wire protocal

Page 5: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Why AMQP: Continued

¤ Key component in Distributed Architecture

¤ Enables Multi-OS, Multi-Language

¤ Reliable, Transactional, Flow-Control, Fault-tolerant

Page 6: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Downsides of AMQP

¤ AMQP 1.0 is almost final ¤ Support resources ¤ Upgrade glitches ¤ Monitoring issues ¤  Investment in the future

Page 7: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Why Erlang?

¤ Functional Language ¤  Immutable Data ¤ Scalable ¤ Reliable, Fault-tolerant

Page 8: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Why RabbitMQ

¤ Built with Erlang ¤ 10K messages per second –

transient mode ¤ 3-5K messages per second –

persistent mode

Page 9: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Why RabbitMQ

¤ Transactions ¤ Open Source ¤ Maintained by VMWare

Page 10: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Broker Infrastructure

Page 11: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Broker Infrastructure

¤ Repeatable Install ¤ Reliable storage ¤ Redundant hardware

Page 12: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Broker Infrastructure: Continued

¤ Cluster of nodes ¤ Disaster Recovery ¤ Logging (such as Splunk) and

monitoring ¤ Operations & Support

Page 13: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Broker Infrastructure: Use Escript

Page 14: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Broker Infrastructure Future?

¤  Integrate Rebar ¤ Continuous Integration Testing ¤ QuickCheck

Page 15: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

RabbitMQ Clients

¤ Any AMQP Clients (Apache) ¤ Ruby ¤ Python ¤ C# ¤ F# (Wrap the C# dll)

Page 16: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Consume.py Part: A

Page 17: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Consume.py Part: B

Page 18: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Consume.py Part: C

Page 19: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Send.py Part: A

Page 20: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Send.py Part: B

Page 21: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Writing RabbitMQ Plugin: WHY

¤ Access internal RabbitMQ functionality

¤ Running in same Erlang VM as broker can increase performance

¤ Leverage your existing infrastructure

Page 22: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Writing RabbitMQ Plugin: WHY NOT

¤ Developers don’t know Erlang ¤ Poorly written plugin could

crash broker ¤ You could lock yourself to

internal API

Page 23: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Stable RabbitMQ Plugin

¤ Rabbitmq-management (replaced Alice)

¤ Rabbitmq-shovel ¤ Rabbitmq-stomp ¤ Rabbitmq-erlang-client

Page 24: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Experimental RabbitMQ Plugin Ideas

¤ Rabbitmq-auth-backend-ldap ¤ Rabbitmq-auth-mechanism-ssl ¤ Rabbitmq-jsonrpc-channel ¤ Rabbitmq-xmpp

Page 25: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Crazy RabbitMQ Plugin Ideas

¤ Distributed Data Structure ¤ Artificial Intelligence ¤ Data Mining ¤ Create a protocol on top ¤ Event Processing

Page 26: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Michael Background

¤ Apple 5 Years ¤ Ascend/Lucent 4 Years ¤ Various Startups

Page 27: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Supervision Tree

Page 28: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Plugin Supervisor

Page 29: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Rabbit RSS Supervisor

Page 30: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Rabbit RSS Worker: Slide A

Page 31: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Rabbit RSS Worker: Slide B

Page 32: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Rabbit RSS Worker: Slide C

Page 33: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Rabbit RSS Worker: Slide D

Page 34: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Rabbit RSS Worker: Slide E

Page 35: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Rabbit RSS Worker: Slide F

Page 36: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

XML Parsing

Page 37: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

RSS.ERL: Slide A

Page 38: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

RSS.ERL: Slide B

Page 39: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

RSS.ERL: Slide C

Page 40: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

RSS.ERL: Slide D

Page 41: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Checkout  source:    HG  clone

Page 42: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Make:    Be  Pa5ent….

Page 43: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Build

Page 44: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Skeleton

Page 45: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Symlink  Plugin

Page 46: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Run  Broker

$ make run (rabbit@rabbit9)1> (rabbit@rabbit9)1>application:which_applications(). {rabbit_rss,"Embedded Rabbit RSS Reader","0.01"},

Page 47: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Test  Broker

$ mkdir test $ vi test/rabbit_rss_tests.erl $ vi Makefile TEST_APPS=amqp_client rabbit_rss TEST_COMMANDS=rabbit_rss_tests:test() START_RABBIT_IN_TESTS=true $ make test

Page 48: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Package  Plugin

Page 49: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Plugin Supporting Machinery

¤ Unit Tests ¤ Source Code ¤ Logger ¤ Printf ¤ AMQP Clients

Page 50: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

How To Build a Plugin

¤ RabbitMQ docs ¤ Source ¤ Examples

Page 51: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Use the Source!

¤ Documentation is hit/miss ¤ Google “erlang lists” ¤ http://www.erlang.org/doc/

apps/stdlib/ ¤ Or skip the docs and go

directly to source ¤  ./lib/stdlib/src/lists.erl

Page 52: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Lists.erl

Page 53: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Logger

¤ Plugin executes in its own process

¤ No plugin stdout ¤ No plugin execution debugger

Page 54: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Logger: Continued

¤ Solution: Erlang’s logger ¤ Output to /var/log/

rabbitmq/<hostname ¤ Nothing to configure

Page 55: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

RSS.erl

Page 56: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

OTP Design Principles

¤ Supervision Tree ¤ Behaviors ¤ Applications ¤ Releases ¤ Release Handling

Page 57: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Machine Learning

¤ The next step for the RSS plugin.

¤ A potential use case for RabbitMQ plugins.

Page 58: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Fisher Classifier For RSS Feeds

¤ Data mining ¤ Classification

Page 59: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Fisher Classifier: Slide A

Page 60: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Fisher Classifier: Slide B

Page 61: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Fisher Classifier: Slide C

Page 62: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Fisher Classifier: Slide D

Page 63: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Fisher Classifier: Slide E

Page 64: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Fisher Classifier: Slide E

Page 65: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Fisher Classifier: Slide F

Page 66: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Fisher Classifier: Slide G

Page 67: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Conclusion

¤ AMQP ¤ Erlang ¤ Python ¤ RSS

Page 68: WRITING PLUGINS WITH RABBITMQ - erlang-factory.com · WRITING PLUGINS WITH RABBITMQ Noah Gift and Michael Vierling . Noah’s Background ! ... Logging (such as Splunk) and monitoring

Questions

¤ Code: https://github.com/mikev/rabbitmq_rss_plugin ¤ Contact: “Noah Gift” [email protected],

“Michael Vierling” [email protected]