SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
WAMP as a platform for composite SOA applications and its implementation on Lua
WAMP stands for Web Application Messaging Protocol. This is an open protocol that implements two patterns within a single protocol: RPC and Publish / Subscribe. As it seems to me, this is a great platform for the Internet of Things, Smart City and in general business applications with a lot of different components and services.
WAMP stands for Web Application Messaging Protocol. This is an open protocol that implements two patterns within a single protocol: RPC and Publish / Subscribe. As it seems to me, this is a great platform for the Internet of Things, Smart City and in general business applications with a lot of different components and services.
WAMP as a platform for composite SOA applications and its implementation on Lua
1.
WAMP as a platform
for composite SOA
applications and its
implementation on Lua
Konstantin Burkalev
@KSDaemon
2.
Few words about me…
2
• Software architect
• 15+ years in IT
• Author and host of podcasts: SDCast & RadioJS
• Active member of WAMP protocol development group
• Author and maintainer of a few WAMP implementations,
some of them are written in Lua
3.
Talk plan
Example of system using WAMP
What is WAMP and how it works
WAMP as basis for SOA applications
Application fields
WAMP client in Lua
WAMP router in Nginx/Lua
3
39.
What is WAMP
• It stands for "Web Application Messaging Protocol"
5
40.
What is WAMP
• It stands for "Web Application Messaging Protocol"
• Is intended for communication between software components in
near real-time
5
41.
What is WAMP
• It stands for "Web Application Messaging Protocol"
• Is intended for communication between software components in
near real-time
• Provides two mechanisms:
• Publish/Subscribe (PubSub)
• Remote Procedure Calls (RPC)
5
42.
What is WAMP
• It stands for "Web Application Messaging Protocol"
• Is intended for communication between software components in
near real-time
• Provides two mechanisms:
• Publish/Subscribe (PubSub)
• Remote Procedure Calls (RPC)
• Bi-directional, ordered
5
43.
What is WAMP
• It stands for "Web Application Messaging Protocol"
• Is intended for communication between software components in
near real-time
• Provides two mechanisms:
• Publish/Subscribe (PubSub)
• Remote Procedure Calls (RPC)
• Bi-directional, ordered
• For communication between clients is required WAMP-router
5
50.
Why WAMP?
• Open specification
• Thoughtful Publish / Subscribe
• Thoughtful Remote Procedure Calls
• Message routing
• Cross-platform
• There are implementations in more than 15 languages
6
64.
Basic WAMP concepts
• Client. Can provide or consume resources, such as subscriptions and RPC.
• Router. Deals with authorization and message routing between clients.
• Peer. Can be a client or a router, must have at least one role.
• Role. Determines the capabilities of the node. There are 4 client roles and 2 router roles.
• Session. It is necessary to identify and authorize clients, announce the role of nodes.
• Realm. Domain, namespace, within which messages are routed.
• Transport. You can use: WebSockets, Raw TCP, Unix sockets and even HTTP Long poll.
• Serializer. Messages are serialized using JSON / MessagePack / CBOR / etc.
• Resource identifiers, URIs. Required for topics, procedures and errors.
19
105.
WAMP as a basis for SOA applications
Distributed architecture
24
106.
WAMP as a basis for SOA applications
Distributed architecture
Loose coupling of components
24
107.
WAMP as a basis for SOA applications
Distributed architecture
Loose coupling of components
A simple and intuitive interface for interaction
24
108.
WAMP as a basis for SOA applications
Distributed architecture
Loose coupling of components
A simple and intuitive interface for interaction
Unified Routing
24
109.
WAMP as a basis for SOA applications
Distributed architecture
Loose coupling of components
A simple and intuitive interface for interaction
Unified Routing
Independence from programming language
24
110.
WAMP as a basis for SOA applications
Distributed architecture
Loose coupling of components
A simple and intuitive interface for interaction
Unified Routing
Independence from programming language
Re-usability of components
24
111.
WAMP as a basis for SOA applications
Distributed architecture
Loose coupling of components
A simple and intuitive interface for interaction
Unified Routing
Independence from programming language
Re-usability of components
WAMP satisfies the requirements of SOA
24
112.
WAMP as ESB
25
WAMP
Router
Service
Providers
Service
Providers
Service
Providers
Service
Providers
Service
Providers
Consumers
Consumers
Consumers
Consumers
Consumers
call RPC
Subscribe to topics
Register RPC
Publish events
Subscribe to topics
Publish events
Сервер
Сервер
Server
113.
WAMP in heterogeneous systems
26
WAMP
Router
File
uploader
(python)
Web
Client
(js)
Backoffice
Client
(c#)
Video
processing
(c++)
Image
processing
(go)
Logger
(ruby)
External
API
Gateway
Client
REST API
(nodejs)
Mobile
Client
(swift)
Backoffice
REST API
(Java)
DB
Mobile
Client
(java)
Realm
Realm
Realm
Сервер
Сервер
Server
115.
WAMP Application fields
27
Distributed applications with a large number of services
116.
WAMP Application fields
27
Distributed applications with a large number of services
Smart homes, Smart cities, Internet of things in General
117.
WAMP Application fields
27
Distributed applications with a large number of services
Smart homes, Smart cities, Internet of things in General
Systems with long-running processes
118.
WAMP Application fields
27
Distributed applications with a large number of services
Smart homes, Smart cities, Internet of things in General
Systems with long-running processes
Easy modern alternative to XMPP, XMLRPC
119.
WAMP Application fields
27
Distributed applications with a large number of services
Smart homes, Smart cities, Internet of things in General
Systems with long-running processes
Easy modern alternative to XMPP, XMLRPC
Network multiplayer games
121.
WAMP: real projects
• Kadecot API Server. Sony Computer Science Laboratories
28
122.
WAMP: real projects
• Kadecot API Server. Sony Computer Science Laboratories
• ParaView. Parallel Data Analysis and Visualization Application, Kitware
28
123.
WAMP: real projects
• Kadecot API Server. Sony Computer Science Laboratories
• ParaView. Parallel Data Analysis and Visualization Application, Kitware
• Record.Evolution. Data-warehouse and Business Intelligence
28
124.
WAMP: real projects
• Kadecot API Server. Sony Computer Science Laboratories
• ParaView. Parallel Data Analysis and Visualization Application, Kitware
• Record.Evolution. Data-warehouse and Business Intelligence
• SmartME smart city project. MDS Lab at the University of Messina
28
125.
WAMP: real projects
• Kadecot API Server. Sony Computer Science Laboratories
• ParaView. Parallel Data Analysis and Visualization Application, Kitware
• Record.Evolution. Data-warehouse and Business Intelligence
• SmartME smart city project. MDS Lab at the University of Messina
• ButterflyDNS. Web UI frontend for BIND DLZ
• Gollard VISION Server Management Subsystem
28
128.
Loowy: WAMP client in Lua
30
• Works in Lua/Luajit environment on top of lua-ev
129.
Loowy: WAMP client in Lua
30
• Works in Lua/Luajit environment on top of lua-ev
• Supports JSON and Msgpack serializers
130.
Loowy: WAMP client in Lua
30
• Works in Lua/Luajit environment on top of lua-ev
• Supports JSON and Msgpack serializers
• Supports a number of features from Advanced Profile
131.
Loowy: WAMP client in Lua
30
• Works in Lua/Luajit environment on top of lua-ev
• Supports JSON and Msgpack serializers
• Supports a number of features from Advanced Profile
• Automatic reconnection and re-subscription
132.
Loowy: WAMP client in Lua
30
• Works in Lua/Luajit environment on top of lua-ev
• Supports JSON and Msgpack serializers
• Supports a number of features from Advanced Profile
• Automatic reconnection and re-subscription
• TODO: Raw socket transport
• TODO: Meta API
• TODO: Challenge-Response Authorization (WAMP-CRA)
• TODO: work on the basis of coroutines
133.
Loowy: api calls examples
31
client = loowy.new("ws://localhost/ws/", { realm = "gv" })
client:publish('sensor.events', { sensorId = 12, temperature = 27})
client:subscribe('sensor.events', function(event)
-- process received event
end)
client:call('dcs.fan.control', true, {
onSuccess = function()
-- fan turned on successfully
end,
onError = function(err)
-- error occurred
end
})
137.
Wiola: WAMP router in Lua
• Works on top of Nginx/Lua module
33
138.
Wiola: WAMP router in Lua
• Works on top of Nginx/Lua module
• Uses Redis for runtime storage
33
139.
Wiola: WAMP router in Lua
• Works on top of Nginx/Lua module
• Uses Redis for runtime storage
• Supports JSON and Msgpack serializers
33
140.
Wiola: WAMP router in Lua
• Works on top of Nginx/Lua module
• Uses Redis for runtime storage
• Supports JSON and Msgpack serializers
• Supports a number of features from Advanced Profile
33
141.
Wiola: WAMP router in Lua
• Works on top of Nginx/Lua module
• Uses Redis for runtime storage
• Supports JSON and Msgpack serializers
• Supports a number of features from Advanced Profile
• TODO: Raw socket transport
• TODO: Meta API
• TODO: lua-resty-postgres
33
147.
Wiola: JSON caveats and limitations
• cJSON
37
148.
Wiola: JSON caveats and limitations
• cJSON
• you cannot specify how to serialize empty tables
37
149.
Wiola: JSON caveats and limitations
• cJSON
• you cannot specify how to serialize empty tables
• lua-resty-libcjson
37
150.
Wiola: JSON caveats and limitations
• cJSON
• you cannot specify how to serialize empty tables
• lua-resty-libcjson
• not able to work with large numbers (int > 32bit)
37
151.
Wiola: JSON caveats and limitations
• cJSON
• you cannot specify how to serialize empty tables
• lua-resty-libcjson
• not able to work with large numbers (int > 32bit)
lua-rapidjson
37
152.
Wiola: JSON caveats and limitations
• cJSON
• you cannot specify how to serialize empty tables
• lua-resty-libcjson
• not able to work with large numbers (int > 32bit)
lua-rapidjson
• So far, no new problems have been found :)
37
154.
Wiola: Runtime storage options
38
• Global variables in memory
155.
Wiola: Runtime storage options
38
• Global variables in memory
• are created every time on request handler
156.
Wiola: Runtime storage options
38
• Global variables in memory
• are created every time on request handler
• problems with concurrent requests
157.
Wiola: Runtime storage options
38
• Global variables in memory
• are created every time on request handler
• problems with concurrent requests
• Module variables loaded in init_by_lua
158.
Wiola: Runtime storage options
38
• Global variables in memory
• are created every time on request handler
• problems with concurrent requests
• Module variables loaded in init_by_lua
• You can read in all workers
159.
Wiola: Runtime storage options
38
• Global variables in memory
• are created every time on request handler
• problems with concurrent requests
• Module variables loaded in init_by_lua
• You can read in all workers
• But the write, thanks to CoW, will create a copy of the module for the VM
160.
Wiola: Runtime storage options
38
• Global variables in memory
• are created every time on request handler
• problems with concurrent requests
• Module variables loaded in init_by_lua
• You can read in all workers
• But the write, thanks to CoW, will create a copy of the module for the VM
• ngx.shared.DICT
161.
Wiola: Runtime storage options
38
• Global variables in memory
• are created every time on request handler
• problems with concurrent requests
• Module variables loaded in init_by_lua
• You can read in all workers
• But the write, thanks to CoW, will create a copy of the module for the VM
• ngx.shared.DICT
• The size of each dictionary is specified in the config file and can not be changed
162.
Wiola: Runtime storage options
38
• Global variables in memory
• are created every time on request handler
• problems with concurrent requests
• Module variables loaded in init_by_lua
• You can read in all workers
• But the write, thanks to CoW, will create a copy of the module for the VM
• ngx.shared.DICT
• The size of each dictionary is specified in the config file and can not be changed
External storage: Redis, Memcache, PostgreSQL, MySQL and others
165.
Wiola: Особенности. lua_code_cache
39
• lua_code_cache off;
• it is convenient to debug the code
166.
Wiola: Особенности. lua_code_cache
39
• lua_code_cache off;
• it is convenient to debug the code
• every require() is executed again in each request
167.
Wiola: Особенности. lua_code_cache
39
• lua_code_cache off;
• it is convenient to debug the code
• every require() is executed again in each request
• Even the modules loaded into init_by_lua are re-executed
168.
Wiola: Особенности. lua_code_cache
39
• lua_code_cache off;
• it is convenient to debug the code
• every require() is executed again in each request
• Even the modules loaded into init_by_lua are re-executed
• lua_code_cache on;
169.
Wiola: Особенности. lua_code_cache
39
• lua_code_cache off;
• it is convenient to debug the code
• every require() is executed again in each request
• Even the modules loaded into init_by_lua are re-executed
• lua_code_cache on;
• for production environment
170.
Wiola: Особенности. lua_code_cache
39
• lua_code_cache off;
• it is convenient to debug the code
• every require() is executed again in each request
• Even the modules loaded into init_by_lua are re-executed
• lua_code_cache on;
• for production environment
• each require() is executed once and is cached
171.
Wiola: Особенности. lua_code_cache
39
• lua_code_cache off;
• it is convenient to debug the code
• every require() is executed again in each request
• Even the modules loaded into init_by_lua are re-executed
• lua_code_cache on;
• for production environment
• each require() is executed once and is cached
• whenever you change the code, you need to reload nginx
173.
Wiola: Publication in luarocks, opm
40
• luarocks: there is one part of
the dependencies, there is no
other:
174.
Wiola: Publication in luarocks, opm
40
• luarocks: there is one part of
the dependencies, there is no
other:
- lua-resty-websocket
175.
Wiola: Publication in luarocks, opm
40
• luarocks: there is one part of
the dependencies, there is no
other:
- lua-resty-websocket
- lua-resty-redis
176.
Wiola: Publication in luarocks, opm
40
• luarocks: there is one part of
the dependencies, there is no
other:
- lua-resty-websocket
- lua-resty-redis
✓ rapidjson
177.
Wiola: Publication in luarocks, opm
40
• luarocks: there is one part of
the dependencies, there is no
other:
- lua-resty-websocket
- lua-resty-redis
✓ rapidjson
✓ lua-resty-hmac
178.
Wiola: Publication in luarocks, opm
40
• luarocks: there is one part of
the dependencies, there is no
other:
- lua-resty-websocket
- lua-resty-redis
✓ rapidjson
✓ lua-resty-hmac
✓ lua-messagepack
179.
Wiola: Publication in luarocks, opm
40
• luarocks: there is one part of
the dependencies, there is no
other:
- lua-resty-websocket
- lua-resty-redis
✓ rapidjson
✓ lua-resty-hmac
✓ lua-messagepack
• opm (OpenResty Package
Manager): accurate to
"reverse":
180.
Wiola: Publication in luarocks, opm
40
• luarocks: there is one part of
the dependencies, there is no
other:
- lua-resty-websocket
- lua-resty-redis
✓ rapidjson
✓ lua-resty-hmac
✓ lua-messagepack
• opm (OpenResty Package
Manager): accurate to
"reverse":
✓ lua-resty-websocket
181.
Wiola: Publication in luarocks, opm
40
• luarocks: there is one part of
the dependencies, there is no
other:
- lua-resty-websocket
- lua-resty-redis
✓ rapidjson
✓ lua-resty-hmac
✓ lua-messagepack
• opm (OpenResty Package
Manager): accurate to
"reverse":
✓ lua-resty-websocket
✓ lua-resty-redis
182.
Wiola: Publication in luarocks, opm
40
• luarocks: there is one part of
the dependencies, there is no
other:
- lua-resty-websocket
- lua-resty-redis
✓ rapidjson
✓ lua-resty-hmac
✓ lua-messagepack
• opm (OpenResty Package
Manager): accurate to
"reverse":
✓ lua-resty-websocket
✓ lua-resty-redis
- rapidjson
183.
Wiola: Publication in luarocks, opm
40
• luarocks: there is one part of
the dependencies, there is no
other:
- lua-resty-websocket
- lua-resty-redis
✓ rapidjson
✓ lua-resty-hmac
✓ lua-messagepack
• opm (OpenResty Package
Manager): accurate to
"reverse":
✓ lua-resty-websocket
✓ lua-resty-redis
- rapidjson
✓ lua-resty-hmac
184.
Wiola: Publication in luarocks, opm
40
• luarocks: there is one part of
the dependencies, there is no
other:
- lua-resty-websocket
- lua-resty-redis
✓ rapidjson
✓ lua-resty-hmac
✓ lua-messagepack
• opm (OpenResty Package
Manager): accurate to
"reverse":
✓ lua-resty-websocket
✓ lua-resty-redis
- rapidjson
✓ lua-resty-hmac
- lua-messagepack
188.
WAMP: Conclusion
• A simple and open Protocol
42
189.
WAMP: Conclusion
• A simple and open Protocol
• RPC and PubSub in one transport/protocol
42
190.
WAMP: Conclusion
• A simple and open Protocol
• RPC and PubSub in one transport/protocol
• Any transport and serialization
42
191.
WAMP: Conclusion
• A simple and open Protocol
• RPC and PubSub in one transport/protocol
• Any transport and serialization
• Allows you to build distributed applications with loosely coupled
components
42
192.
WAMP: Conclusion
• A simple and open Protocol
• RPC and PubSub in one transport/protocol
• Any transport and serialization
• Allows you to build distributed applications with loosely coupled
components
• There are implementations in many languages
42
193.
WAMP: Conclusion
• A simple and open Protocol
• RPC and PubSub in one transport/protocol
• Any transport and serialization
• Allows you to build distributed applications with loosely coupled
components
• There are implementations in many languages
• Open source
42
194.
WAMP: Conclusion
• A simple and open Protocol
• RPC and PubSub in one transport/protocol
• Any transport and serialization
• Allows you to build distributed applications with loosely coupled
components
• There are implementations in many languages
• Open source
• A small but friendly community
42
197.
WAMP: Conclusion
• Useful architectural solution
• A great option for your IoT project! (IMHO: better than MQTT)
43
198.
WAMP: Conclusion
• Useful architectural solution
• A great option for your IoT project! (IMHO: better than MQTT)
• Try WAMP:
43
199.
WAMP: Conclusion
• Useful architectural solution
• A great option for your IoT project! (IMHO: better than MQTT)
• Try WAMP:
• Already have nginx/openresty? — try Wiola (bit.ly/wiola-router)
43
200.
WAMP: Conclusion
• Useful architectural solution
• A great option for your IoT project! (IMHO: better than MQTT)
• Try WAMP:
• Already have nginx/openresty? — try Wiola (bit.ly/wiola-router)
• Are you using a docker?
43
201.
WAMP: Conclusion
• Useful architectural solution
• A great option for your IoT project! (IMHO: better than MQTT)
• Try WAMP:
• Already have nginx/openresty? — try Wiola (bit.ly/wiola-router)
• Are you using a docker?
• docker pull 421p/wiola
43
202.
WAMP: Conclusion
• Useful architectural solution
• A great option for your IoT project! (IMHO: better than MQTT)
• Try WAMP:
• Already have nginx/openresty? — try Wiola (bit.ly/wiola-router)
• Are you using a docker?
• docker pull 421p/wiola
• docker pull crossbario/crossbar
43
203.
WAMP: Conclusion
• Useful architectural solution
• A great option for your IoT project! (IMHO: better than MQTT)
• Try WAMP:
• Already have nginx/openresty? — try Wiola (bit.ly/wiola-router)
• Are you using a docker?
• docker pull 421p/wiola
• docker pull crossbario/crossbar
• WAMP client for every taste and color (wamp-proto.org/implementations/)
43
204.
Thank you for attention!
And your questions :)
44
Konstantin Burkalev
• Mail: kostik@ksdaemon.ru
• Twitter: @KSDaemon
• GitHub: KSDaemon
• Blog: blog.ksdaemon.ru
• SDCast: sdcast.ksdaemon.ru
0 likes
Be the first to like this
Views
Total views
768
On SlideShare
0
From Embeds
0
Number of Embeds
6
You have now unlocked unlimited access to 20M+ documents!
Unlimited Reading
Learn faster and smarter from top experts
Unlimited Downloading
Download to take your learnings offline and on the go
You also get free access to Scribd!
Instant access to millions of ebooks, audiobooks, magazines, podcasts and more.
Read and listen offline with any device.
Free access to premium services like Tuneln, Mubi and more.