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

View File

@ -5,5 +5,5 @@ core:
logDisableTimestamp: true logDisableTimestamp: true
logsPath: ./logs logsPath: ./logs
tracing: tracing:
rabbitMQEnabled: false rabbitMQEnabled: true
rabbitMQURI: "amqp://guest:guest@localhost:5672/" rabbitMQURI: "amqp://guest:guest@localhost:5672/"

27
main.go
View File

@ -14,8 +14,7 @@ import (
var quit = make(chan struct{}) var quit = make(chan struct{})
var queue amqp.Queue var channel *amqp.Channel
var channel amqp.Channel
func main() { func main() {
parser := parser.Init("./configurations/beelzebub.yaml", "./configurations/services/") parser := parser.Init("./configurations/beelzebub.yaml", "./configurations/services/")
@ -37,16 +36,6 @@ func main() {
channel, err := conn.Channel() channel, err := conn.Channel()
failOnError(err, "Failed to open a channel") failOnError(err, "Failed to open a channel")
defer channel.Close() 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 // Init Protocol strategies
@ -88,9 +77,19 @@ func traceStrategyStdout(event tracer.Event) {
}).Info("New Event") }).Info("New Event")
//TODO check amqp.Channe //TODO check amqp.Channe
if queue != (amqp.Queue{}) { if channel != nil {
eventJSON, err := json.Marshal(event) 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( err = channel.Publish(
"", "",