Slide 1

Slide 1 text

RabbitMQ Overview raf optimal rabbitmq guide from beginner to advanced PDF rabbitmq in action PDF rabbitmq in depth PDF

Slide 2

Slide 2 text

ToC 1. Why Message Queue? 2. Routing & Management a. Routing Structure b. Exchanges c. Virtual Host d. High Availability 3. Message a. Message Properties b. Publish c. Subscribe(Consume) 2

Slide 3

Slide 3 text

Why Message Queue? 1. Redundancy via persistence Queues help with redundancy by making the process that reads the message confirm that it completed the transaction and it is safe to remove it. 2. Mitigate traffic spikes By queuing the data we can be assured the data will be persisted and then be processed eventually, even if that means it takes a little longer than usual due to a high traffic spike. 3. Batching for Efficiency 4. Asynchronous Messaging https://stackify.com/message-queues-12-reasons/ 3

Slide 4

Slide 4 text

Routing Structure 4

Slide 5

Slide 5 text

Exchanges (1/3) 1. Direct binding key exactly matches the routing key of the message. 2. Header “x-match” “all”: all the header key-value pairs must match “any”: at least one of the headers key-value pairs must match 3. Fanout routes messages to all of the queues that are bound to it 5

Slide 6

Slide 6 text

4. Topic binding pattern matches the routing key of the message. “*” can substitute for exactly one word. “#” can substitute for zero or more words. Exchanges (2/3) ad.vast.* ad.native.clicked ad.vast.clicked ad.native.impressed #.clicked #.landed #.impressed 6

Slide 7

Slide 7 text

Exchanges (3/3) Alternate Exchange : unroutable messages Dead letter Exchange : nack messages https://www.compose.com/articles/configuring-rabbitmq-exchanges-queues-and-bindings-part-2/ https://www.rabbitmq.com/ae.html 7

Slide 8

Slide 8 text

Virtual Host provides logical grouping and separation of resources. https://www.rabbitmq.com/vhosts.html 8

Slide 9

Slide 9 text

High Availability Mirrored Queue https://jack-vanlightly.com/blog/2018/8/31/rabbitmq-vs-kafka-part-5-fault-tolerance-and-high-availability-with-rabbitmq https://www.rabbitmq.com/ha.html 9

Slide 10

Slide 10 text

message-id: message identifier delivery-mode: transient(1), persistent(2) for RPC response reply-to: reply routing key correlation-id: request message-id Message Properties 10

Slide 11

Slide 11 text

Publish 11 Publish(exchange, key, mandatory, immediate, msg) Mandatory: return error when no queue is bound that matches the routing key Immediate: return error when no consumer on the matched queue is ready to accept the delivery. Confirm() / NotifyPublish() / NotifyConfirm() https://godoc.org/github.com/streadway/amqp#Channel.Publish

Slide 12

Slide 12 text

Consume(queue, consumer, autoAck, exclusive, noLocal, noWait, args) AutoAck: Automatically acknowledging deliveries Exclusive: if Exclusive=false, the server will fairly distribute deliveries across multiple consumers. Ack(multiple) / Nack(multiple, requeue) multiple: multiple messages can be acknowledged with a single method requeue: the server will attempt to requeue the message Qos(prefetchCount, prefetchSize, global) global: Qos settings apply to all existing and future consumers on all channels on the same connection. Subscribe 12 http://www.rabbitmq.com/blog/2012/04/25/rabbitmq-performance-measurements-part-2/