Skip to content

Commit 44ac1c1

Browse files
committed
docs: document producer-consumer example with RabbitMQ in README
- Add README for the producer-consumer example with RabbitMQ - Include prerequisites, installation steps, and running instructions for both producer and consumer Signed-off-by: appleboy <[email protected]>
1 parent 12834dc commit 44ac1c1

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

_example/producer-consumer/README.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Producer-Consumer Example with RabbitMQ
2+
3+
This example demonstrates a simple producer-consumer pattern using RabbitMQ in Go.
4+
5+
## Prerequisites
6+
7+
- Go 1.22 or later
8+
- RabbitMQ server
9+
10+
## Installation
11+
12+
1. Clone the repository:
13+
14+
```sh
15+
git clone https://github.com/appleboy/golang-queue.git
16+
cd golang-queue/rabbitmq/_example/producer-consumer
17+
```
18+
19+
2. Install dependencies:
20+
21+
```sh
22+
go mod tidy
23+
```
24+
25+
## Running the Example
26+
27+
### Start RabbitMQ
28+
29+
Ensure RabbitMQ server is running. You can start RabbitMQ using Docker:
30+
31+
```sh
32+
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
33+
```
34+
35+
### Producer
36+
37+
The producer sends messages to the RabbitMQ queue.
38+
39+
1. Navigate to the producer directory:
40+
41+
```sh
42+
cd producer
43+
```
44+
45+
2. Run the producer:
46+
47+
```sh
48+
go run main.go
49+
```
50+
51+
### Consumer
52+
53+
The consumer receives messages from the RabbitMQ queue.
54+
55+
1. Navigate to the consumer directory:
56+
57+
```sh
58+
cd consumer
59+
```
60+
61+
2. Run the consumer:
62+
63+
```sh
64+
go run main.go
65+
```

0 commit comments

Comments
 (0)