Replies: 2 comments 4 replies
-
I'm having a hard time following your description. Please provide a script I can run that demonstrates the behavior you describe. This script should do the following:
|
Beta Was this translation helpful? Give feedback.
2 replies
-
Here it's
consumer1 package main
import (
"log"
amqp "github.com/rabbitmq/amqp091-go"
)
func failOnError(err error, msg string) {
if err != nil {
log.Fatalf("%s: %s", msg, err)
}
}
func main() {
conn, err := amqp.Dial("amqp://guest:guest@localhost:5672")
failOnError(err, "Failed to connect to RabbitMQ")
defer conn.Close()
ch, err := conn.Channel()
failOnError(err, "Failed to open a channel")
defer ch.Close()
q, err := ch.QueueDeclare(
"queue", // name
true, // durable
false, // delete when unused
false, // exclusive
false, // no-wait
nil, // arguments
)
failOnError(err, "Failed to declare a queue")
failOnError(ch.QueueBind(q.Name, "bind.super1", "direct", false, nil), "Failed to bind")
msgs, err := ch.Consume(
q.Name, // queue
"", // consumer
true, // auto-ack
false, // exclusive
false, // no-local
false, // no-wait
nil, // args
)
failOnError(err, "Failed to register a consumer")
forever := make(chan bool)
go func() {
for d := range msgs {
log.Printf("Received a message: %s, %s", d.Body, d.RoutingKey)
}
}()
log.Printf(" [*] Waiting for messages. To exit press CTRL+C")
<-forever
} consumer2
producer
So with this config |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Found a somehow weird topics behavior. Go examples with empty queue name work just fine when it just creates a new tmp queue but here's my scenario
I do have one queue, let's call it
messaging
That queue has multiple bindings:
bind.super
bind.super1
bind.super2
wrong.ok
I bind and consume this way:
What is weird, rounting works just fine with bind.*, but if
wrong.ok
is being consumed by everyone ignoringbind.xyz
. Is it expected behavior and is there a way to filter those out besides some extra go code?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions