Skip to content

munisense/syntax-workshop-2021

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Syntax Message Queue Workshop 2021

In this workshop we will learn the basic concepts of a Message Queue, and we will learn how to write a small Golang application to interact with RabbitMQ as our message broker.

Prerequisites to participate

Note for Windows users

Please use powershell (and not cmd) and change the volume mount as shown below

--volume="${pwd}:/app"

instead of:

--volume="$PWD:/app"

Step 1 - get a single message from a shared queue

Lets get a message from a queue!

This application will try to get a single message from a queue called "results".

docker run --rm -it --volume="$PWD:/app" -w /app golang:1-alpine go run cmd/step1/main.go

Step 2 - consume messages from a shared queue

We can do better than polling for every single message. Let's consume from a queue instead.

docker run --rm -it --volume="$PWD:/app" -w /app golang:1-alpine go run cmd/step2/main.go

Step 3 - create your own exclusive queue

No more shared queue, we want to receive all messages.

This program will create an exclusive queue and bind it to the exchange called "results" with routing key "#".

The routing key determines what messages your queue will receive, a # means all messages.

docker run --rm -it --volume="$PWD:/app" -w /app golang:1-alpine go run cmd/step3/main.go

Step 4 - create your own exclusive queue and only receive a specific set of messages

Up until now we have been receiving all messages. In this example we will use the routing key to tell RabbitMQ we only want to receive LAeq messages.

docker run --rm -it --volume="$PWD:/app" -w /app golang:1-alpine go run cmd/step4/main.go

Step 5 - publish something to the exchange

But what it you want to send data to the queue? That goes through an exchange! We will publish something to the results exchange and then use the code from step 4 to receive this message! Note that if you don't use a routing key (like step 2) you will receive these messages mixed with our prepared messages.

docker run --rm -it --volume="$PWD:/app" -w /app golang:1-alpine go run cmd/step5/main.go

Links

About

Message Queue Workshop we gave for Studievereniging Syntax

Topics

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •