Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Latest commit

 

History

History
105 lines (74 loc) · 6.79 KB

README.md

File metadata and controls

105 lines (74 loc) · 6.79 KB

School of RabbitMQ in Elixir

This is a workshop through out which one develops a simple RabbitMQ applicaiton in Elixir.

Repo structure

  • master holds the end solution
  • each step has its own branch
    • the branches are named with step/{ORIDINAL}-{EXERCISE-SHORT-DESC}, e.g. (step/0-connect-to-rabbit)
    • the beginning of a branch is tagged with step-{ORIDINAL}-start, e.g. (step-0-start) to see what a completion of one step takes via a diff
    • HEAD of a branch contains the final state for the step
    • if a "step branch" changes, it is merged to master and possibly the master has to be merged to all the subsequent "step branches"
  • README at the master branch holds instructions to the correspondins steps

The workshop

To complete the workshop an instance of the RabbitMQ server is required. One can be started with docker using the docker-compose.yml provided: docker-compose up.

This will spawn a RabbitMQ container and create the following ports bindings (host->container): 5672:5672 and 15672:15672. They are used for AMQP and RabbitMQ server Managment UI respectively (http://localhost:15672).

Step 0: Connections and Channels

  1. Open test/rabbit_hole/protocol/connection_test.exs to see how a connection is established and channels are opened
  2. Run the tests: mix test test/rabbit_hole/protocol/connection_test.exs

Step 1: Simple producer and consumer

Managing queues

  1. Open test/rabbit_hole/protocol/queue_declare_test.exs to see how a queue is declared
  2. Run the tests mix test test/rabbit_hole/protocol/queue_declare_test.exs

Publising and consuming

  1. Open test/rabbit_hole/protocol/publish_consume_test.exs to see how a message can be published to and consumed from a queue

  2. Run the tests mix test test/rabbit_hole/protocol/publish_consume_test.exs

  3. Comment out the queue deletion operation in the first test in test/rabbit_hole/protocol/publish_consume_test.exs, run it:

    mix test test/rabbit_hole/protocol/publish_consume_test.exs:23

and see the message enqueued in the my_queue through the the management UI: http://localhost:15672/#/queues (user/pass: guest/guest).

Simple producer and consumer implementation

  1. Checkout at step-1-start tag: git checkout step-1-start.
  2. Open test/rabbit_hole/producer_consumer_test.exs and see the expected behaviour of the RabbitHole.Producer and the RabbitHole.Consumer.
  3. Implement the producer and consumer modules.
  4. Check the solution by looking at the diff between the tag and the head of the 1-simple-producer-consumer branch: step-1-start...step/1-simple-producer-consumer.

Step 2: Message routing

Managing exchanges

  1. Open test/rabbit_hole/protocol/exchange_declare_test.exs to see how to declare an exchange.
  2. Run the tests: mix test --trace test/rabbit_hole/protocol/exchange_declare_test.exs.

Publishing to and consuming from different topics

  1. Checkout at step-2-start tag: git checkout step-2-start.
  2. Open test/rabbit_hole/task/producer_consumer_test.exs and see the expected behaviour of the RabbitHole.Task.Producer and the RabbitHole.Task.Consumer.
  3. Implement the producer and consumer modules.
  4. Check the solution by looking at the diff between the tag and the head of the 2-message-routing: step-2-start...step/2-message-routing.

Step 3: Data integrity

Handling Publisher Confirms

  1. Open test/rabbit_hole/protocol/publish_with_confirm_test.exs to see how to use the Publisher confirms.
  2. Run the tests: mix test --trace test/rabbit_hole/protocol/publish_with_confirm_test.exs

Handling Consumer Acknowledgments

  1. Open test/rabbit_hole/protocol/consume_with_ack_test.exs to see how to use the Publisher confirms.
  2. Run the tests: mix test --trace test/rabbit_hole/protocol/consume_with_ack_test.exs

Publishng and consuming tasks with Confirms and Acks

  1. Checkout at step-3-start tag: git checkout step-3-start.
  2. Open test/rabbit_hole/task/producer_consumer_with_data_integrity_test.exs and see the expected behaviour of the RabbitHole.Task.Producer and the RabbitHole.Task.Consumer with added Publisher Confirms and Consumer Acks respectively.
  3. Extend the producer and consumer modules.
  4. Check the solution by looking at the diff between the tag and the head of the 3-data-integrity: step-3-start...step/3-data-integrity.