Download - Asynchronous Microservices in nodejs
![Page 1: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/1.jpg)
Bruno PedroNovember 2015
Asynchronous Microservices in node.js
![Page 2: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/2.jpg)
Summary• why microservices
• synchronous vs asynchronous topologies
• broker approach
• code examples
• patterns
![Page 3: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/3.jpg)
Why Microservices• organised around business capabilities
• following a decentralised governance
• and a decentralised data management
• automated infrastructure
• designed for failure
![Page 4: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/4.jpg)
in Martin Fowler, "Microservices"
![Page 5: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/5.jpg)
Microservices
• loosely coupled
• with a specific responsibility
• designed around business needs
• connected through a common interface
![Page 6: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/6.jpg)
HTTP
HTTP
HTTP
HTTP
![Page 7: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/7.jpg)
Synchronous
![Page 8: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/8.jpg)
Latency
![Page 9: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/9.jpg)
Asynchronous
![Page 10: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/10.jpg)
Asynchronous
![Page 11: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/11.jpg)
Complexity
![Page 12: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/12.jpg)
SMTPA
A
Broker
![Page 13: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/13.jpg)
SMTPA
BC
D
E
AB
D C
E
![Page 14: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/14.jpg)
Really?
![Page 15: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/15.jpg)
![Page 16: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/16.jpg)
![Page 17: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/17.jpg)
AMQP• Advanced Message Queueing Protocol
• interoperable: loosely coupled clients and servers
• advanced publish and subscribe
• transactional, if needed
• supported by node.js
![Page 18: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/18.jpg)
AMQP
![Page 19: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/19.jpg)
AMQP
amqplib
![Page 20: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/20.jpg)
AMQP
amqplib
var amqp = require('amqplib/callback_api');
amqp.connect('amqp://localhost', function(err, conn) { conn.createChannel(function(err, ch) { var q = 'hello';
ch.assertQueue(q, {durable: false}); ch.sendToQueue(q, new Buffer('Hello World!')); console.log(" [x] Sent 'Hello World!'"); }); });
in RabbitMQ Tutorials
![Page 21: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/21.jpg)
AMQP
amqplibvar amqp = require('amqplib/callback_api');
amqp.connect('amqp://localhost', function(err, conn) { conn.createChannel(function(err, ch) { var q = 'hello';
ch.assertQueue(q, {durable: false}); console.log(" [*] Waiting for messages in %s.", q); ch.consume(q, function(msg) { console.log(" [x] Received %s”, msg.content.toString()); }, {noAck: true}); }); });
in RabbitMQ Tutorials
![Page 22: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/22.jpg)
AMQP HTTP
Webhook
![Page 23: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/23.jpg)
Patterns• work queue
• pubsub system
• webhook
• message routing
• backpressure
• RPC
![Page 24: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/24.jpg)
Asynchronous Microservices• loosely coupled
• agile to changes
• event based
• organised around business capabilities
• connected through the message broker
AMQP
![Page 25: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/25.jpg)
Wrap-up• microservices advantages
• asynchronous over synchronous
• broker approach
• easy to implement
• patterns
![Page 26: Asynchronous Microservices in nodejs](https://reader034.vdocuments.site/reader034/viewer/2022051006/58f9add5760da3da068b9c63/html5/thumbnails/26.jpg)
+
Sean O’ConnorLead Engineer
It's great to see a tool like API Changelog come along. (…) as an API provider, it's always
a challenge to communicate to users when changes happen.
Get in touch!
Bruno Pedro
Thank you