47
Instant Integration into the AMQP Cloud with Apache Qpid Messenger Rafael Schloming Principle Software Engineer @ Red Hat [email protected]

Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

  • Upload
    others

  • View
    14

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Instant Integration into the AMQP Cloud with Apache Qpid Messenger

Rafael SchlomingPrinciple Software Engineer @ Red [email protected]

Page 2: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Overview● Introduction● Messaging● AMQP● Proton● Demo● Summary

Page 3: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Introduction● AMQP 1.0

– OASIS Standard

– Messaging Protocol

● Proton: A toolkit for speaking AMQP– The AMQP Protocol Engine API

– The AMQP Messenger API

● Part of the Apache Qpid project– Qpid is the home for AMQP at Apache

Page 4: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messaging● Tightly Coupled

WarehouseStore Front

Page 5: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messaging● Tightly Coupled

WarehouseStore Front

:-(

:-(

Page 6: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messaging● Loosely Coupled

WarehouseStore Front Order Queue

Page 7: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messaging● Loosely Coupled

WarehouseStore Front Order Queue

:-(

Page 8: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messaging● Loosely Coupled

WarehousesStore Fronts Order Queue

Page 9: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messaging● Message

– addresses are rendezvous points● flexible n – n communication topologies

– properties available for semantic routing

Properties

to: addresscolor: yellow

Body

...

Page 10: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messaging

ConsumersProducers Queue

● Queues

Page 11: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messaging

ConsumersProducers Queue

● Queues

Page 12: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messaging

SubscribersPublishers Topic

● Topics

Page 13: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messaging

SubscribersPublishers Topic

● Topics

Page 14: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messaging

SubscribersPublishers Topic

● Topics

Page 15: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messaging

EndpointsEndpoints Infrastructure

● Heterogeneous

Page 16: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Proprietary Messaging

EndpointsEndpoints Proprietary Infrastructure

Page 17: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Proprietary Messaging● difficult to port

– requires rewriting apps to different API

● difficult to integrate– requires app level bridging and translation

● platforms limited to vendor provided choices

Page 18: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

AMQP 1.0● Ratified as an OASIS standard in Oct 2012

– Developed over several years by an industry working group including:

● Technology vendors– Axway Software, Huawei Technologies, IIT Software,

INETCO Systems, Kaazing, Microsoft, Mitre Corporation, Primeton Technologies, Progress Software, Red Hat, SITA, Software AG, Solace Systems, VMWare, WSO2, Zenika

● User firms– Back of America, Credit Suisse, Deutsche Boerse,

Goldman Sachs, JPMorgan Chase

Page 19: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

AMQP 1.0● Concisely expresses core messaging

semantics– flow control

– settlement

– transactions

– data binding

● Suitable as a wire protocol for a wide range of message oriented applications

Page 20: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

AMQP 1.0

EndpointsEndpoints AMQP EnabledInfrastructure

● AMQP Enabled Infrastucture

Page 21: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

AMQP 1.0

EndpointsEndpoints AMQP EnabledInfrastructure

● Heterogeneous Infrastructure

Page 22: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

AMQP 1.0

EndpointsEndpoints AMQP Cloud

● Standard + Secure = Open Deployments

Page 23: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

AMQP 1.0 Implementations● Apache Qpid

– C++ and Java brokers

● Apache ActiveMQ– multiprotocol message broker

● Azure Service Bus– PaaS

● Swift MQ– JMS broker + client

● Rabbit MQ

Page 24: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Apache Qpid Proton● Proton is a protocol implementation

– Previous attempts to standardize messaging have been client/server based, i.e. RPC

– AMQP 1.0 is a protocol specification● Network oriented: Symmetric, Decentralized● Provides intermediated messaging semantics, but

does not restrict to hub and spoke topology● Not just a standard way to talk to a traditional

broker

– AMQP 1.0 makes a protocol implementation possible

Page 25: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Apache Qpid Proton● Traditional MOM transformed

– Traditional MOMs conflate both● store and forward infrastructure● specialized application behaviors

– special queues: last value, ring queues– message transformation

– Driven by Scalability and Standardization

● With AMQP 1.0, these features can be– distributed, scalable, heterogeneous

Page 26: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Apache Qpid Proton● Many things benefit from speaking AMQP

– A concise expression of a very general set of messaging semantics

● Flow control● Settlement● Transactions● Data binding

– Not everyone wants to implement all this down to the wire

Page 27: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Apache Qpid Proton● Goals

– Make it easy to speak AMQP● minimal dependencies● minimal threading assumptions● multilingual

– C, Java, Javascript– C Bindings in python, ruby, php, perl, ...

● multi-platform– Linux/unix, windows, android, iOS

Page 28: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Apache Qpid Proton

Server Logic

AMQPProtocol Engine

Server I/O

Client Application

AMQP MessengerAMQP

Protocol Engine

Client I/O

● Protocol Engine

Page 29: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Protocol Engine● NOT a traditional “RPC-like” pattern:

– protocol implementation does I/O● Coupled to OS interfaces, I/O strategy, threading

model

invoke()

encode()

write()

dispatch()

decode()

read()

App App

Page 30: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Protocol Engine● Engine pattern:

– application does I/O

– engine encapsulates protocol state● pure state machine, no dependencies, no callbacks

invoke() output() write() read()

Engine

input() dispatch()

Engine

App App

Page 31: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Protocol Engine● Engine interface: “top” and “bottom” half

– Top half● traditional protocol interface in non blocking form

– establish senders and receivers, send/recv message data

– Bottom half● transport interface, inverted

– normal transport pushes bytes to a socket– inverted transport pulls bytes from the engine

Engine

Top Half Bottom Half

Page 32: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Protocol Engine● Echo Server

Echo EngineBytes Out = Bytes In

Bytes In Bytes Out

Page 33: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Protocol Engine● Echo Server

Echo EngineBytes Out = Bytes In

Bytes In Bytes Out

Query Interface

Page 34: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Protocol Engine● Request/Response Server

Request/Response EngineBytes Out = F(Bytes In)

Bytes In Bytes Out

Query Interface

Page 35: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Protocol Engine● Request/Response Server

Request/Response EngineBytes Out = Ctl(Bytes In)

Bytes In Bytes Out

Query/Control Interface

Page 36: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Protocol Engine● Generalized Server

Generalized EngineBytes Out = F(Bytes In, Ctl)

Bytes In Bytes Out

Query/Control Interface

Page 37: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Protocol Engine● Generalized Endpoint

Generalized EngineBytes Out = F(Bytes In, Ctl)

Bytes In Bytes Out

Query/Control Interface

Page 38: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Protocol Engine● Generalized AMQP Engine

Transport(Bottom Half)

Bytes Out = F(Bytes In, Ctl)Bytes In Bytes Out

Stateful Query/Control Interface

AMQP Connection(Top Half)

bind/unbind

Page 39: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Protocol Engine● Benefit: flexibility

– Single protocol implementation can be shared● Used in a simple client● Easy to embed into existing servers

– Thread agnostic● works with single threaded and multithreaded

servers of any architecture

– Easy to swig● pure data structure● no callbacks● simple interface

Page 40: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Protocol Engine

EndpointsEndpoints AMQP Cloud

● Multiplatform + Multilingual = Protons Everywhere

+

+

+

+

+

+

+ ++ +

+ +

Page 41: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messenger

messenger = Messenger()

messenger.start()

msg = Message()msg.address = "0.0.0.0"msg.body = u"Hello World!"

messenger.put(msg)messenger.send()

messenger.stop()

messenger = Messenger()messenger.subscribe("~0.0.0.0")messenger.start()

msg = Message()

while True:  messenger.recv()  while messenger.incoming:    messenger.get(msg)    print msg.body

messenger.stop()

Sending Receiving

Page 42: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messenger● Message oriented, not connection oriented

– (re) creates and pools the minimal number of connections behind the scenes

● simplifies failover

– topology is invisible to application

● Simple, but not a toy– batch oriented interface

● high performance

Page 43: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Messenger

messenger = Messenger()

messenger.outgoing_window = 100messenger.start()

msg = Message()msg.address = "0.0.0.0"msg.body = u"Hello World!"

tracker = messenger.put(msg)messenger.send()print messenger.status(tracker)

messenger.stop()

messenger = Messenger()messenger.subscribe("~0.0.0.0")messenger.start()

msg = Message()

while True:  messenger.recv()  while messenger.incoming:    messenger.get(msg)    print msg.body    messenger.accept()

messenger.stop()

Sending Reliably Receiving Reliably

Page 44: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Message● mutable and reusable holder of content

– works with batch send● more performance

– doesn't conflate delivery with message● flexible: modify a received message and resend it

● data binding from AMQP to native types● usable with Messenger or Engine

Page 45: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Demo

Messenger(Python)

Order DB

Order Queue (Service Bus)

Order Queue (Active MQ)

Order Tracking(PHP)

submit

update

Page 46: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

Summary● AMQP 1.0 is a new kind of messaging

– brings messaging to the masses

● Proton– The AMQP Protocol Engine

● advanced architecture● based on years of enterprise experience

– The AMQP Messenger API● simple but powerful programming API

● This is the basis of next gen applications

Page 47: Instant Integration into the AMQP Cloud with Apache Qpid ...archive.apachecon.com/na2013/presentations/26-Tuesday/Tapping_… · Instant Integration into the AMQP Cloud with Apache

More Information● http://qpid.apache.org/proton● [email protected]● http://www.amqp.org