Presentation is loading. Please wait.

Presentation is loading. Please wait.

AMQP, Erlang, and RabbitMQ

Similar presentations


Presentation on theme: "AMQP, Erlang, and RabbitMQ"— Presentation transcript:

1 AMQP, Erlang, and RabbitMQ
OOI Cyberinfrastructure Design Meeting San Diego, 17th-19th October 2007 Matthias Radestock October 18, 2007

2 So you want to build a computing infrastructure for ocean observation …
…that transfers, routes, transforms, processes and stores a variety of data streams, and works, so it needs to be evolves, so it needs to be distributed reliable & resilient manageable secure scaleable portable pluggable interoperable … like an enterprise messaging system! October 18, 2007

3 AMQP aims to become THE standard for enterprise messaging
Everyone uses without thinking, so then why is universal commercial business messaging so hard? → need an Open Standard Protocol for Message Oriented Middleware AMQP aims to become THE standard for enterprise messaging Made to satisfy real needs: created by users and technologists working together in development for 3+ years, went public on June 20th 2006 “business dialtone” October 18, 2007

4 AMQP’s place in the “stack”
Product Layer Use Standard User Applications bank CDL-BPM-CEP treasury ESB / SOA / EDA settlement WS-* “Document Model” reports FpML WCF “Rich Object Model” positions Transaction participant trades FIX, FAST MQ Store & forward orders JMS AMQP Guaranteed Delivery send/ack AMQP Tibco Content based routing (1-Many, 1-1) ticks Utility Services e.g. exchange access links Cisco Network (TCP/IP, UDP, SCTP) data October 18, 2007

5 Comparison with some other protocols
SMTP – unreliable, slow HTTP – synchronous, unreliable, no routing XMPP – no delivery fidelity or queue management FTP – point to point, transient, does not work well with NAT/SSL MQ – exactly once TCP – at least once, reliable but short lived, no app level state mgmt UDP – fast but has no delivery guarantees AMQP - can do all of the above as ‘use cases’ … and switch between them October 18, 2007

6 How does it work? Queue File Transfer Exchange Queue Messaging Queue Bindings Transactions any language (C, C++, Java, C#, Python, Javascript, Erlang, Lisp, Ruby, Tcl, PHP, …) any model (native, JMS, Mule, WCF, …) any payload (binary, XML, SOAP, JSON, …) any transport (TCP, SCTP, HTTP, …) any platform (desktop, router, mobile, EC2, …) reliable interoperable manageable performant scaleable October 18, 2007

7 A typical AMQP client program
# Addresses where a particular broker is reachable. endpoints = [amqp.Endpoint('hostname', 5672), amqp.Endpoint('alternate', 5673)] # Construct a session. session = amqp.Session("1234", 600, endpoints) # Set up some resources on the broker. session.ExchangeDeclare("xname",amqp.ExchangeTypes.DIRECT) session.QueueDeclare("qname") session.QueueBind("xname","qname","routingkey") # Publish a message. session.MessageTransfer("xname","routingkey","body") # Set up a consumer. session.MessageConsume("qname",MyConsumer(session)) class MyConsumer: def __init__(self,session): self.session = session def handle_MessageTransfer(self,destination,exchange, routingkey,body): print "Received message: " + body return amqp.Constants.ACCEPT October 18, 2007

8 Under the covers – AMQP Layering
Application queues, exchanges, messages, transactions, … API calls Model command segmentation / assembly, ordering and acknowledgement commands Execution frameset sequencing frameset (dis)assembly frame flow control reliability (exactly once) and failover framesets Session frames Framing (de)multiplexing by channel/stream heartbeating framing, integrity check bytes / packets Transport October 18, 2007

9 Communication between peers
messages Application Application Model commands Model controls Execution Execution control frames Session Session control frames Framing Framing Transport October 18, 2007

10 Under the covers: session reattachment
October 18, 2007

11 AMQP - Inclusive Governance
Protocol Products JPMorgan D/Borse Credit Suisse Goldman Sachs TWIST Novell 29West Envoy Apache Community Feedback iMatix OpenAMQ Red Hat Enterprise Messaging Iona Celtix AM RabbitMQ Cisco Network AMQP Working Group controls the standard Diverse products implement the standard October 18, 2007

12 So you want to build a computing infrastructure for ocean observation …
…that transfers, routes, transforms, processes and stores a variety of data streams, and works, so it needs to be evolves, so it needs to be distributed reliable & resilient manageable secure scaleable portable pluggable interoperable … like a telecommunications system! October 18, 2007

13 No language was well suited for telecom systems development
Erlang History 2007: A New Book! 1996: Open Telecom Platform No language was well suited for telecom systems development 1998: Open Source Erlang 1994: First Product 1993: Distributed Erlang 1987: Early Erlang Prototype projects 1993: The First Book 1984: Ericsson Computer Science Lab formed 1991: First fast implementation October 18, 2007

14 Erlang Highlights Functional Concurrent Soft real-time Robust
High abstraction level Concise readable programs No mutable state Functional Concurrent Soft real-time Robust Distributed Hot code loading External interfaces Portable October 18, 2007

15 Light-weight processes
Erlang Highlights Functional Concurrent Soft real-time Robust Distributed Hot code loading External interfaces Portable Light-weight processes Highly scalable Message Passing October 18, 2007

16 Erlang Highlights: Concurrency
Processes communicate by asynchronous message passing receive {start} -> ……… {stop} -> ……… {data,X,Y} -> ……… end Pid ! {data,12,13} October 18, 2007

17 Per-process garbage collection
Erlang Highlights Functional Concurrent Soft real-time Robust Distributed Hot code loading External interfaces Portable Response times in the low milliseconds Per-process garbage collection October 18, 2007

18 Erlang Highlights Functional Concurrent Soft real-time Robust
Distributed Hot code loading External interfaces Portable Simple and consistent error recovery Supervision hierarchies "Program for the correct case" October 18, 2007

19 Erlang Highlights: Robustness
Cooperating processes may be linked together October 18, 2007

20 Erlang Highlights: Robustness
When a process terminates, an exit signal is sent to all linked processes … and the termination is propagated October 18, 2007

21 Erlang Highlights: Robustness
Exit signals can be trapped and received as messages receive {‘EXIT’,Pid,...} -> ... end October 18, 2007

22 Erlang Highlights: Robustness
Robust systems can be built by layering “Supervisors” “Workers” October 18, 2007

23 Explicit or transparent
Erlang Highlights Functional Concurrent Soft real-time Robust Distributed Hot code loading External interfaces Portable Explicit or transparent distribution Network-aware runtime system October 18, 2007

24 Erlang Highlights: Distribution
B ! Msg C ! Msg Erlang Run-Time System Erlang Run-Time System network October 18, 2007

25 Erlang Highlights: Distribution
Simple Remote Procedure Call {rex, Node} ! {self(), {apply, M, F, A}}, receive {rex, Node, What} -> What end loop() -> receive {From, {apply, M, F, A}} -> Answer = apply(M, F, A), From ! {rex, node(), Answer} loop() end. October 18, 2007

26 Enables non-stop operation
Erlang Highlights Easily change code in a running system Enables non-stop operation Simplifies testing Functional Concurrent Soft real-time Robust Distributed Hot code loading External interfaces Portable October 18, 2007

27 Erlang Highlights Functional Concurrent Soft real-time Robust
Distributed Hot code loading External interfaces Portable "Ports" to the outside world behave as Erlang processes October 18, 2007

28 Erlang Highlights: External Interfaces
process Port Port ! {self(), {command, [1,2,3]}}, receive {Port, {data, Info}} -> ... end October 18, 2007

29 Erlang Highlights Functional Concurrent Soft real-time Robust
Distributed Hot code loading External interfaces Portable Erlang runs on a Virtual Machine ported to UNIX, Windows, VxWorks, OS X, … Supports heterogeneous networks. October 18, 2007

30 T O P Open Telecom Platform Applications, Libraries & Tools
System Design Principles O P T October 18, 2007

31 October 18, 2007

32 Credits Alexis Richardson, CohesiveFT – for providing much of the AMQP material Francesco Cesarini, Erlang Consulting – for providing much of the Erlang material Tony Garnock-Jones, LShift – for the sample code Matthew Arrott – for inviting me Thank you! October 18, 2007

33 Backup slides October 18, 2007

34 AMQP features In some ways like email but:
What goes in must come out Very fast - think big - global scale communication In some ways like TCP and HTTP, but delivers true MESSAGING Routing and addressing - “buy.ibm.100” Guaranteed Delivery Delegation - the concept of a middleman → security, reliability, translation, … October 18, 2007

35 AMQP version history and roadmap
0-8 routing Q4’06 0-9 clarifications & bug fixes, experimental work-in-progress extensions Q4’07 0-10 guaranteed delivery, transport independence, general tidying up Q1’08 0-11 management, security, federation, addressing Q2’08 1-0 release October 18, 2007

36 Under the covers: session creation
October 18, 2007

37 Under the covers: configuration
October 18, 2007

38 Under the covers: message transfer
October 18, 2007

39 Mule binding <mule-configuration id="RabbitMQ_Demo" version="1.0"> <model name="rabbitmqDemo"> <mule-descriptor name="Mulebot“ implementation="com.rabbitmq.examples.muledemo.Mulebot"> <inbound-router> <endpoint address="amqp://localhost/?vhost=/&realm=/data& exchange=chat&exchange-type=fanout&routing-key="/> </inbound-router> <outbound-router matchAll="true"> <router className="org.mule.routing.outbound.OutboundPassThroughRouter"> </router> </outbound-router> </mule-descriptor> </model> </mule-configuration> October 18, 2007

40 WCF binding service = new ServiceHost(typeof(Calculator),
new Uri("soap.amq://dev.rabbitmq.com:5672/")); service.AddServiceEndpoint(typeof(ICalculator), new RabbitMQDualBinding(), "Calculator"); service.Open(); fac = new ChannelFactory<ICalculator>( new RabbitMQDualBinding() { ClientBaseAddress = new Uri("soap.amq://dev.rabbitmq.com:5672/")}, "soap.amq://dev.rabbitmq.com:5672/Calculator"); fac.Open(); calc = fac.CreateChannel(); Console.WriteLine("{0} + {1} = {2}", x, y, calc.Add(3, 4)); ((IChannel)calc).Close(); service.Close(); October 18, 2007

41 Erlang Highlights: High-level Constructs
Parsing an IP Datagram using the Bit Syntax -define(IP_VERSION, 4). -define(IP_MIN_HDR_LEN, 5). …… DgramSize = size(Dgram), <<?IP_VERSION:4, HLen:4, SrvcType:8, TotLen:16, ID:16, Flgs:3, FragOff:13, TTL:8, Proto:8, HdrChkSum:16, SrcIP:32, DestIP:32, Body/binary>> = Dgram, if (HLen >= 5) and (4*HLen =< DgramSize) -> OptsLen = 4*(HLen - ?IP_MIN_HDR_LEN), <<Opts:OptsLen/binary, Data/binary>> = Body, ….. end. October 18, 2007


Download ppt "AMQP, Erlang, and RabbitMQ"

Similar presentations


Ads by Google