a few words about wamp

71
A few words about Konstantin Burkalev, @KSDaemon MoscowJS, july 2014

Upload: konstantin-burkalev

Post on 05-Dec-2014

251 views

Category:

Technology


6 download

DESCRIPTION

Presentation about WAMP (WebSocket Application Messaging Protocol), it's architecture, implementations and possible use cases.

TRANSCRIPT

Page 1: A few words about WAMP

A few words about

Konstantin Burkalev, @KSDaemonMoscowJS, july 2014

Page 2: A few words about WAMP

≠WAMP

Windows, Apache, MySQL, PHP

Page 3: A few words about WAMP

Application level protocol, "implementing 2 patterns:

• Publish/Subscribe (PubSub)"• Remote Procedure Calls (RPC)

=WAMP

Page 4: A few words about WAMP

Basic components and definitions

• Resource identifier • Transport • Serializer • Session • Realm - domain, namespace • Peer • Client • Router • Role

Page 5: A few words about WAMP

Architecture

Page 6: A few words about WAMP

Resource identifiers

• Subscriptions • Procedures • Errors

Required for:

are URI-based• system.send.file • chat.message • users.admins.message • user.profile.updated

Page 7: A few words about WAMP

Serialization and data types

• integer • string • bool • list (array) • dict

Supported serializers:• JSON • MsgPack

Supported data types:Required: Additional:

any, depends on serializer

Page 8: A few words about WAMP

Messages and payload• [HELLO,  Realm|uri,  Details|dict]  "

• [PUBLISH,  Request|id,  Options|dict,  Topic|uri]  • [PUBLISH,  Request|id,  Options|dict,  Topic|uri,  Arguments|list]  • [PUBLISH,  Request|id,  Options|dict,  Topic|uri,  Arguments|list,  ArgumentsKw|dict]  "

• [CALL,  Request|id,  Options|dict,  Procedure|uri]  • [CALL,  Request|id,  Options|dict,  Procedure|uri,  Arguments|list]  • [CALL,  Request|id,  Options|dict,  Procedure|uri,  Arguments|list,  ArgumentsKw|dict]  "

• [RESULT,  CALL.Request|id,  Details|dict]  • [RESULT,  CALL.Request|id,  Details|dict,  YIELD.Arguments|list]  • [RESULT,  CALL.Request|id,  Details|dict,  YIELD.Arguments|list,  YIELD.ArgumentsKw|dict]

• Array | List • Hash-table | Dictionary

Payload may be supplied as:

Page 9: A few words about WAMP

Transport

• Websocket • Raw TCP • HTTP long-polling (under dev) • Unix sockets

• Based on messages • Messages are ordered • Bidirectional message flow

Page 10: A few words about WAMP

Transport and Session

RouterClient

Page 11: A few words about WAMP

Transport and Session

RouterClientHELLO

Page 12: A few words about WAMP

Transport and Session

RouterClientHELLO

WELCOME

Page 13: A few words about WAMP

Transport and Session

RouterClientHELLO

WELCOME

ABORT

Page 14: A few words about WAMP

Transport and Session

RouterClientHELLO

WELCOME

GOODBYE

ABORT

Page 15: A few words about WAMP

Transport and Session

RouterClientHELLO

WELCOME

GOODBYE

ABORT

GOODBYE

Page 16: A few words about WAMP

Transport and Session

RouterClientHELLO

WELCOME

GOODBYE

ABORT

GOODBYE

GOODBYE

Page 17: A few words about WAMP

Transport and Session

RouterClientHELLO

WELCOME

GOODBYE

ABORT

GOODBYE

GOODBYE

GOODBYE

Page 18: A few words about WAMP

Publish / Subscribe

BrokerPublisher Subscriber

Page 19: A few words about WAMP

Publish / Subscribe

BrokerPublisher SubscriberSUBSCRIBE

Page 20: A few words about WAMP

Publish / Subscribe

BrokerPublisher SubscriberSUBSCRIBE

SUBSCRIBED

Page 21: A few words about WAMP

Publish / Subscribe

BrokerPublisher SubscriberSUBSCRIBE

SUBSCRIBED

ERROR

Page 22: A few words about WAMP

Publish / Subscribe

BrokerPublisher SubscriberSUBSCRIBE

SUBSCRIBED

ERROR

PUBLISH

Page 23: A few words about WAMP

Publish / Subscribe

BrokerPublisher SubscriberSUBSCRIBE

SUBSCRIBED

ERROR

PUBLISH

PUBLISHED

Page 24: A few words about WAMP

Publish / Subscribe

BrokerPublisher SubscriberSUBSCRIBE

SUBSCRIBED

ERROR

PUBLISH

PUBLISHED

ERROR

Page 25: A few words about WAMP

Publish / Subscribe

BrokerPublisher SubscriberSUBSCRIBE

SUBSCRIBED

ERROR

PUBLISH

PUBLISHED

ERROR

EVENT

Page 26: A few words about WAMP

Publish / Subscribe

BrokerPublisher SubscriberSUBSCRIBE

SUBSCRIBED

UNSUBSCRIBE

ERROR

PUBLISH

PUBLISHED

ERROR

EVENT

Page 27: A few words about WAMP

Publish / Subscribe

BrokerPublisher SubscriberSUBSCRIBE

SUBSCRIBED

UNSUBSCRIBE

UNSUBSCRIBED

ERROR

PUBLISH

PUBLISHED

ERROR

EVENT

Page 28: A few words about WAMP

Publish / Subscribe

BrokerPublisher SubscriberSUBSCRIBE

SUBSCRIBED

UNSUBSCRIBE

UNSUBSCRIBED

ERROR

ERROR

PUBLISH

PUBLISHED

ERROR

EVENT

Page 29: A few words about WAMP

Remote Procedure Calls

DealerCaller Callee

Page 30: A few words about WAMP

Remote Procedure Calls

DealerCaller CalleeREGISTER

Page 31: A few words about WAMP

Remote Procedure Calls

DealerCaller CalleeREGISTER

REGISTERED

Page 32: A few words about WAMP

Remote Procedure Calls

DealerCaller CalleeREGISTER

REGISTERED

ERROR

Page 33: A few words about WAMP

Remote Procedure Calls

DealerCaller CalleeREGISTER

REGISTERED

ERROR

CALL

Page 34: A few words about WAMP

Remote Procedure Calls

DealerCaller CalleeREGISTER

REGISTERED

ERROR

CALL

INVOCATION

Page 35: A few words about WAMP

Remote Procedure Calls

DealerCaller CalleeREGISTER

REGISTERED

ERROR

CALL

INVOCATION

YIELD

Page 36: A few words about WAMP

Remote Procedure Calls

DealerCaller CalleeREGISTER

REGISTERED

ERROR

CALL

INVOCATION

YIELD

ERROR

Page 37: A few words about WAMP

Remote Procedure Calls

DealerCaller CalleeREGISTER

REGISTERED

ERROR

CALL

RESULT

INVOCATION

YIELD

ERROR

Page 38: A few words about WAMP

Remote Procedure Calls

DealerCaller CalleeREGISTER

REGISTERED

ERROR

CALL

RESULT

INVOCATION

YIELD

ERROR

ERROR

Page 39: A few words about WAMP

Remote Procedure Calls

DealerCaller CalleeREGISTER

REGISTERED

UNREGISTER

ERROR

CALL

RESULT

INVOCATION

YIELD

ERROR

ERROR

Page 40: A few words about WAMP

Remote Procedure Calls

DealerCaller CalleeREGISTER

REGISTERED

UNREGISTER

UNREGISTERED

ERROR

CALL

RESULT

INVOCATION

YIELD

ERROR

ERROR

Page 41: A few words about WAMP

Remote Procedure Calls

DealerCaller CalleeREGISTER

REGISTERED

UNREGISTER

UNREGISTERED

ERROR

ERROR

CALL

RESULT

INVOCATION

YIELD

ERROR

ERROR

Page 42: A few words about WAMP

Profiles

• Basic profile • Advanced profile

Set of features within each pattern (PubSub, RPC)

Page 43: A few words about WAMP

Advanced profile

• Session Management • Authentication • Heartbeat

Page 44: A few words about WAMP

Advanced profile

• Publish / Subscribe • Black/white lists • Publisher identification • Pattern-based subscriptions • Meta events • Subscriber list • Events list

Page 45: A few words about WAMP

Advanced profile

• Remote Procedure Calls • black/white lists • Caller identification • Pattern-based RPC registration • Canceling calls • Progressive calls

Page 46: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

WAMP Router(realm 2)

Page 47: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

subscribe to ‘ready.for.chat’

subscribe to ‘ready.for.chat’

WAMP Router(realm 2)

Page 48: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

WAMP Router(realm 2)

subscribe to ‘chat.taken’

subscribe to ‘chat.taken’

Page 49: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

subscribe to ‘user.chat.id1235’

WAMP Router(realm 2)

Page 50: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

publish event to ‘ready.for.chat’

WAMP Router(realm 2)

Page 51: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

receive event in ‘ready.for.chat’

receive event in ‘ready.for.chat’

WAMP Router(realm 2)

Page 52: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

publish event to ‘chat.taken’

WAMP Router(realm 2)

Page 53: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

receive event in ‘chat.taken’

WAMP Router(realm 2)

Page 54: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

publish event to ‘user.chat.id1235’

WAMP Router(realm 2)

Page 55: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

receive event in ‘user.chat.id1235’

WAMP Router(realm 2)

Page 56: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

subscribe to ‘user.chat.id2425’

WAMP Router(realm 2)

Page 57: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

publish event to ‘ready.for.chat’

WAMP Router(realm 2)

Page 58: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

receive event in ‘ready.for.chat’

receive event in ‘ready.for.chat’

WAMP Router(realm 2)

Page 59: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

publish event to ‘chat.taken’

WAMP Router(realm 2)

Page 60: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

receive event in ‘chat.taken’WAMP Router

(realm 2)

Page 61: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

publish event to ‘user.chat.id2425’

WAMP Router(realm 2)

Page 62: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

receive event in ‘user.chat.id2425’

WAMP Router(realm 2)

Page 63: A few words about WAMP

Usage exampleOnline consultant

Browser

Embedded app

client

Browser

Embedded app

client

Browser

Backoffice app

client

Browser

Backoffice app

client

WAMP Router(realm 1)

Browser

Embedded app

client

Browser

Embedded app

client

WAMP Router(realm 2)

Page 64: A few words about WAMP

Usage example

Browser

Browser

Server side infrastructure

WAMP Router

Mobile

Desktop

REGI

STER

RPC

REG

ISTE

R RP

C REGISTER RPC

SUBSCRIBE to TOPICs

Internal service 1

SUBSCRIBE to TOPICs

Internal service 2

Internal service 3

Frontoffice app

client

Frontoffice app

client

CRUDN

gin

x /

HAPr

oxy

CRUD

CRUDBackoffice

appclient

SUBSCRIBE to TOPICs

PUBLISH Event PUBL

ISH

Even

t

CALL RPCs

Ngin

x /

HAPr

oxy

Backoffice app

client

DB

CRUD CRUD

Backoffice appserverside

Frontoffice appserverside

Integration solution

Page 65: A few words about WAMP

Prov

ides R

PC

Publ

ish e

vent

s

Subscribe to topicsProv

ides

RPC

Publish events

Service Provider 1

Service Provider 2

Service Provider 3

Service Provider 4

Service Provider 5

Publish events

WAMP Router(realm 1, realm 2, realm 3, ....)

Call R

PC

Call RPC

Subs

cribe

to to

pics

Publ

ish e

vent

s

Consumer 1 Consumer 2 Consumer 3 Consumer 4 Consumer 5

Usage exampleWAMP as a platform for SOA solutions

Page 66: A few words about WAMP

Usage exampleWAMP as a platform for SOA solutions

• Unified service bus • Asynchronous procedures execution • Standardization of interaction interfaces • Minimal overhead • Flexible infrastructure • Isolation and loose coupling of services • Easy to connect new services

Page 67: A few words about WAMP

Implementations

• JavaScript!• Autobahn|JS (browser, node.js) • Wampy.js (browser)

• Java!• Autobahn|Android (soon)

• .NET!• WampSharp (under dev)

• PHP!• Thurway

Clients• Python!

• Autobahn|Python • C++!

• Autobahn|Cpp • Erlang!

• Erwa • Objective-C!

• MDWamp • Lua (under dev)

Routers• Python!

• Autobahn|Python • Crossbar.io

• Erlang!• Erwa

• PHP!• Thurway

• Lua!• Wiola

Page 68: A few words about WAMP

Conclusion

• Simple and open protocol • RPC + PubSub out of the box • Unified routing • Transport and serialization for every taste • Minimal overhead • Native use in web applications • Allows you to build distributed applications with

loosely coupled components • Many implementations in different languages • Open source & community

Page 69: A few words about WAMP

Useful links

• http://wamp.ws!• Description • Specification • Implementations

• https://groups.google.com/group/wampws • http://autobahn.ws • https://github.com/crossbario/crossbar/wiki

• Crossbar.io • Client examples in different languages

Page 70: A few words about WAMP

That’s all folks!"Any questions

?

Page 71: A few words about WAMP

Konstantin Burkalev

Thank you!

• Mail: [email protected] • Twitter: @KSDaemon • GitHub: KSDaemon • Blog: blog.ksdaemon.ru