Tech News
← Back to articles

Building a message queue with only two UNIX signals

read original related products more articles

Have you ever asked yourself what if we could replace any message broker with a very simple one using only two UNIX signals? Well, I’m not surprised if you didn’t. But I did. And I want to share my journey of how I achieved it.

If you want to learn about UNIX signals, binary operations the easy way, how a message broker works under the hood, and a bit of Ruby, this post is for you.

And if you came here just because of the clickbait title, I apologize and invite you to keep reading. It’ll be fun, I promise.

It’s all about UNIX

A few days ago, I saw some discussion on the internet about how we could send messages between processes. Many people think of sockets, which are the most common way to send messages, even allowing communication across different machines and networks. Some don’t even realize that pipes are another way to send messages between processes:

$ echo 'hello' | base64 aGVsbG8K

Here’s what’s happening:

The process echo is started with the content “hello”

is started with the content “hello” echo is a program that prints the message to STDOUT

is a program that prints the message to STDOUT Through the pipe, the content in STDOUT is sent directly to the STDIN of the base64 process

... continue reading