Configured tracing on rabbitMQ

This commit is contained in:
Mario
2022-05-21 12:24:07 +02:00
parent 1085ab405e
commit 08ca432fc9
2 changed files with 14 additions and 15 deletions

27
main.go
View File

@ -14,8 +14,7 @@ import (
var quit = make(chan struct{})
var queue amqp.Queue
var channel amqp.Channel
var channel *amqp.Channel
func main() {
parser := parser.Init("./configurations/beelzebub.yaml", "./configurations/services/")
@ -37,16 +36,6 @@ func main() {
channel, err := conn.Channel()
failOnError(err, "Failed to open a channel")
defer channel.Close()
queue, err = channel.QueueDeclare(
"event", // name
false, // durable
false, // delete when unused
false, // exclusive
false, // no-wait
nil, // arguments
)
failOnError(err, "Failed to declare a queue")
}
// Init Protocol strategies
@ -88,9 +77,19 @@ func traceStrategyStdout(event tracer.Event) {
}).Info("New Event")
//TODO check amqp.Channe
if queue != (amqp.Queue{}) {
if channel != nil {
eventJSON, err := json.Marshal(event)
failOnError(err, "Failed to publish a message")
failOnError(err, "Failed to Marshal Event")
queue, err := channel.QueueDeclare(
"event",
false,
false,
false,
false,
nil,
)
failOnError(err, "Failed to declare a queue")
err = channel.Publish(
"",