Upload
konstantin-burkalev
View
254
Download
6
Embed Size (px)
DESCRIPTION
Presentation about WAMP (WebSocket Application Messaging Protocol), it's architecture, implementations and possible use cases.
Citation preview
A few words about
Konstantin Burkalev, @KSDaemonMoscowJS, july 2014
≠WAMP
Windows, Apache, MySQL, PHP
Application level protocol, "implementing 2 patterns:
• Publish/Subscribe (PubSub)"• Remote Procedure Calls (RPC)
=WAMP
Basic components and definitions
• Resource identifier • Transport • Serializer • Session • Realm - domain, namespace • Peer • Client • Router • Role
Architecture
Resource identifiers
• Subscriptions • Procedures • Errors
Required for:
are URI-based• system.send.file • chat.message • users.admins.message • user.profile.updated
Serialization and data types
• integer • string • bool • list (array) • dict
Supported serializers:• JSON • MsgPack
Supported data types:Required: Additional:
any, depends on serializer
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:
Transport
• Websocket • Raw TCP • HTTP long-polling (under dev) • Unix sockets
• Based on messages • Messages are ordered • Bidirectional message flow
Transport and Session
RouterClient
Transport and Session
RouterClientHELLO
Transport and Session
RouterClientHELLO
WELCOME
Transport and Session
RouterClientHELLO
WELCOME
ABORT
Transport and Session
RouterClientHELLO
WELCOME
GOODBYE
ABORT
Transport and Session
RouterClientHELLO
WELCOME
GOODBYE
ABORT
GOODBYE
Transport and Session
RouterClientHELLO
WELCOME
GOODBYE
ABORT
GOODBYE
GOODBYE
Transport and Session
RouterClientHELLO
WELCOME
GOODBYE
ABORT
GOODBYE
GOODBYE
GOODBYE
Publish / Subscribe
BrokerPublisher Subscriber
Publish / Subscribe
BrokerPublisher SubscriberSUBSCRIBE
Publish / Subscribe
BrokerPublisher SubscriberSUBSCRIBE
SUBSCRIBED
Publish / Subscribe
BrokerPublisher SubscriberSUBSCRIBE
SUBSCRIBED
ERROR
Publish / Subscribe
BrokerPublisher SubscriberSUBSCRIBE
SUBSCRIBED
ERROR
PUBLISH
Publish / Subscribe
BrokerPublisher SubscriberSUBSCRIBE
SUBSCRIBED
ERROR
PUBLISH
PUBLISHED
Publish / Subscribe
BrokerPublisher SubscriberSUBSCRIBE
SUBSCRIBED
ERROR
PUBLISH
PUBLISHED
ERROR
Publish / Subscribe
BrokerPublisher SubscriberSUBSCRIBE
SUBSCRIBED
ERROR
PUBLISH
PUBLISHED
ERROR
EVENT
Publish / Subscribe
BrokerPublisher SubscriberSUBSCRIBE
SUBSCRIBED
UNSUBSCRIBE
ERROR
PUBLISH
PUBLISHED
ERROR
EVENT
Publish / Subscribe
BrokerPublisher SubscriberSUBSCRIBE
SUBSCRIBED
UNSUBSCRIBE
UNSUBSCRIBED
ERROR
PUBLISH
PUBLISHED
ERROR
EVENT
Publish / Subscribe
BrokerPublisher SubscriberSUBSCRIBE
SUBSCRIBED
UNSUBSCRIBE
UNSUBSCRIBED
ERROR
ERROR
PUBLISH
PUBLISHED
ERROR
EVENT
Remote Procedure Calls
DealerCaller Callee
Remote Procedure Calls
DealerCaller CalleeREGISTER
Remote Procedure Calls
DealerCaller CalleeREGISTER
REGISTERED
Remote Procedure Calls
DealerCaller CalleeREGISTER
REGISTERED
ERROR
Remote Procedure Calls
DealerCaller CalleeREGISTER
REGISTERED
ERROR
CALL
Remote Procedure Calls
DealerCaller CalleeREGISTER
REGISTERED
ERROR
CALL
INVOCATION
Remote Procedure Calls
DealerCaller CalleeREGISTER
REGISTERED
ERROR
CALL
INVOCATION
YIELD
Remote Procedure Calls
DealerCaller CalleeREGISTER
REGISTERED
ERROR
CALL
INVOCATION
YIELD
ERROR
Remote Procedure Calls
DealerCaller CalleeREGISTER
REGISTERED
ERROR
CALL
RESULT
INVOCATION
YIELD
ERROR
Remote Procedure Calls
DealerCaller CalleeREGISTER
REGISTERED
ERROR
CALL
RESULT
INVOCATION
YIELD
ERROR
ERROR
Remote Procedure Calls
DealerCaller CalleeREGISTER
REGISTERED
UNREGISTER
ERROR
CALL
RESULT
INVOCATION
YIELD
ERROR
ERROR
Remote Procedure Calls
DealerCaller CalleeREGISTER
REGISTERED
UNREGISTER
UNREGISTERED
ERROR
CALL
RESULT
INVOCATION
YIELD
ERROR
ERROR
Remote Procedure Calls
DealerCaller CalleeREGISTER
REGISTERED
UNREGISTER
UNREGISTERED
ERROR
ERROR
CALL
RESULT
INVOCATION
YIELD
ERROR
ERROR
Profiles
• Basic profile • Advanced profile
Set of features within each pattern (PubSub, RPC)
Advanced profile
• Session Management • Authentication • Heartbeat
Advanced profile
• Publish / Subscribe • Black/white lists • Publisher identification • Pattern-based subscriptions • Meta events • Subscriber list • Events list
Advanced profile
• Remote Procedure Calls • black/white lists • Caller identification • Pattern-based RPC registration • Canceling calls • Progressive calls
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)
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)
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’
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
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
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
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
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
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
That’s all folks!"Any questions
?
Konstantin Burkalev
Thank you!
• Mail: [email protected] • Twitter: @KSDaemon • GitHub: KSDaemon • Blog: blog.ksdaemon.ru