presentation
Post on 03-Aug-2015
14 Views
Preview:
TRANSCRIPT
Disclaimer (AKA about me)
● Experience– Node.js? Lots
– NoSQL? Lots.
– Messaging? Little
● Backend Developer at ThinxNet.com
(http://thinxnet.com/#jobs)
Ready to serve. How?
● Event collection and processing● Webapp, mobile app● Backoffice and support apps, notification services etc.● Reporting, third party software integration etc● REST approach:
– Lots of requests
– Parsing of data is blocking
– Avoid choking devices
– Communication overhead
– Error management
About RabbitMQ
● Messaging broker based on AMQP protocol ● Platform/language independent● Extensible (Erlang)● Persistent message queues● Node.js drivers (node-amqp, rabbit.js...)
Exchanges and topics
● Publisher and subscriber. Simple as that.● Get message, ack or reject (nack) it.● Subscribers listen on a queue● Publishers talk to an exchange● Exchange routes to queues based on topics
PUSH-PULL/WORKER
● Round-robin distribution● Worker socket.ack() is explicit (rabbit.js
driver)● Prefetch sets the number of msgs received● Problem: concurrent/sequential
modification?
Content-based routing
● Erlang extensions? Not standard.● App-side:
– Keep internal mini-queue
– Do not ack a msg if it's not first on local queue
– Hold internal messages based on internal “topic”, ie “user.<ID>.save” - hold msgs for that user
– Item.update() instead of item.save()
● Gets nasty fast, should minimize these scenarios
REST API with MQ
● REQUEST/REPLY for immediate responses● Other patterns for direct access
– REST API just forwards the message
– replies will go by other route
● Pub/sub is easy!
Error handling
● Uncaught exceptions are covered● Retry logic is simplified – push incomplete
messages to a 'fixer' queue, requeue failed jobs or when no resources
● Dedicated error handling
Error handling
● Uncaught exceptions are covered● Retry logic is simplified – push incomplete
messages to a 'fixer' queue, requeue failed jobs or when no resources
● Dedicated error handling
Testing
● No good known mocks, please help● RabbitMQ always on on Jenkins machine● Test handlers directly
Info sources
● https://www.rabbitmq.com/● http://www.squaremobius.net/rabbit.js/● http://www.manning.com/videla/
top related