Skip to content

Receiving messages based on a pattern (topics) & RPC call

Notifications You must be signed in to change notification settings

jellydn/rabbitmq-demo

Repository files navigation

Welcome to rabbitmq-demo 👋

Version License: MIT Twitter: jellydn

Receiving messages based on a pattern (topics)

Install

Run below command with antfu/ni: 💡 Use the right package manager

ni

Then run RabbitMQ server with Docker.

cd mq
sh run.sh start

Usage 1: Receiving messages base on pattern

Open 1st terminal with below command

nr receive "info.*"

Then open other terminal to emit message to rabbit mq

nr emit info.1 hello
nr emit info.2 demo

Usage 2: RPC (NodeJS <- -> Go)

RPC Server in GO and RPC Client in Nodejs

To run the RPC server written in Go, navigate to the go-rpc directory and run the main.go file:

cd go-rpc-server
go run main.go

then run the RPC client written in Node.js

yarn rpc-client

RPC Server in Nodejs and RPC Client in Go

To run the RPC server written in Node.js

yarn rpc-server

To run the RPC client written in Go, navigate to the go-rpc-client directory and run the main.go file:

cd go-rpc-client
go run main.go '{"a": 2, "b": 3}'

Run tests

nr test

Author

👤 Huynh Duc Dung

Show your support

Give a ⭐️ if this project helped you!