Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create events queue once #25

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func init() {
// It is called from the main function
// and it is blocking
func InitOrDie() {
queueArgs := amqp091.Table{}

err := apiconnections.RabbitMQConnection.GetChannel().ExchangeDeclare(
messagebuscontracts.ExchangeRor, // name
Expand Down Expand Up @@ -165,31 +164,4 @@ func InitOrDie() {
if err != nil {
panic(err)
}

ApiEventsqueue, err = apiconnections.RabbitMQConnection.GetChannel().QueueDeclare(
ApiEventsQueueName, // name
true, // durable
true, // delete when unused
false, // exclusive
false, // no-wait
queueArgs, // arguments, non quorum queue
)
if err != nil {
args := [...]any{ApiEventsQueueName, err}
msg := fmt.Sprintf("could not declare exchange %s,", args)
rlog.Fatal(msg, err)
}

err = apiconnections.RabbitMQConnection.GetChannel().QueueBind(
ApiEventsQueueName, // queue name
"", // routing key
messagebuscontracts.ExchangeRorEvents, // exchange
false,
nil,
)
if err != nil {
args := [...]any{ApiEventsQueueName, err}
msg := fmt.Sprintf("could not bind queue %s,", args)
rlog.Fatal(msg, err)
}
}
18 changes: 10 additions & 8 deletions internal/rabbitmq/apirabbitmqhandler/api_rabbitmq_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ import (
func StartListening() {
go func() {
config := rabbitmqhandler.RabbitMQListnerConfig{
Client: apiconnections.RabbitMQConnection,
QueueName: apirabbitmqdefinitions.ApiEventsQueueName,
Consumer: "",
AutoAck: false,
Exclusive: false,
NoLocal: false,
NoWait: false,
Args: nil,
Client: apiconnections.RabbitMQConnection,
QueueName: apirabbitmqdefinitions.ApiEventsQueueName,
Consumer: "",
AutoAck: false,
Exclusive: false,
NoLocal: false,
NoWait: false,
Args: nil,
QueueAutoDelete: true,
Exchange: messagebuscontracts.ExchangeRorEvents,
}
rabbithandler := rabbitmqhandler.New(config, apimessagehandler{})
_ = apiconnections.RabbitMQConnection.RegisterHandler(rabbithandler)
Expand Down