-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (42 loc) · 950 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"fmt"
"os"
"github.com/entropyx/protos"
"github.com/entropyx/rabbitgo"
"github.com/golang/protobuf/proto"
"github.com/streadway/amqp"
)
func rabbitConn() (conn *rabbitgo.Connection) {
c := &rabbitgo.Config{
Host: os.Getenv("AMQP_HOST"),
Username: os.Getenv("AMQP_USER"),
Password: os.Getenv("AMQP_PASS"),
Vhost: os.Getenv("AMQP_VHOST"),
Port: 5672,
}
conn, err := rabbitgo.NewConnection(c)
fmt.Println(c)
if err != nil {
fmt.Println(err)
}
return conn
}
func main() {
conn := rabbitConn()
producerConfig := &rabbitgo.ProducerConfig{
Exchange: "entropy",
RoutingKey: "montserrat",
}
producer, err := conn.NewProducer(producerConfig)
if err != nil {
fmt.Println(err)
}
publishing := &amqp.Publishing{
Body: []byte("Hello World"),
}
err = producer.PublishRPC(publishing, func(delivery *rabbitgo.Delivery) {
fmt.Println(string(delivery.Body))
})
fmt.Println(err)
}