Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RabbitMQ Overview

Buzzvil
January 22, 2020

RabbitMQ Overview

Buzzvil

January 22, 2020
Tweet

More Decks by Buzzvil

Other Decks in Programming

Transcript

  1. RabbitMQ Overview raf optimal rabbitmq guide from beginner to advanced

    PDF rabbitmq in action PDF rabbitmq in depth PDF
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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/