38 lines
821 B
Go
38 lines
821 B
Go
package sylvilagus
|
|
|
|
import (
|
|
"log"
|
|
)
|
|
|
|
import (
|
|
"github.com/streadway/amqp"
|
|
)
|
|
|
|
func CreateHelloTopology(connection *amqp.Connection) (*amqp.Channel, error) {
|
|
channel, err := connection.Channel()
|
|
if err != nil {
|
|
log.Println("Failed to get channel!: ", err)
|
|
return nil, err
|
|
}
|
|
|
|
err = channel.ExchangeDeclare("hello-exchange", "direct", true, false, false, false, nil)
|
|
if err != nil {
|
|
log.Println("Failed to declare exchange!: ", err)
|
|
return nil, err
|
|
}
|
|
|
|
_, err = channel.QueueDeclare("hello-queue", false, false, false, false, nil)
|
|
if err != nil {
|
|
log.Println("Failed to declare queue!: ", err)
|
|
return nil, err
|
|
}
|
|
|
|
err = channel.QueueBind("hello-queue", "hola", "hello-exchange", false, nil)
|
|
if err != nil {
|
|
log.Println("Failed to bind to queue!: ", err)
|
|
return nil, err
|
|
}
|
|
|
|
return channel, nil
|
|
}
|