Skip to content

Instantly share code, notes, and snippets.

@dipeshhkc
Created December 30, 2022 23:06
Show Gist options
  • Save dipeshhkc/0ff1af452152189c291acd9f0d58d812 to your computer and use it in GitHub Desktop.
Save dipeshhkc/0ff1af452152189c291acd9f0d58d812 to your computer and use it in GitHub Desktop.
var RabbitChannel *amqp.Channel
var rabbitConn *amqp.Connection
//SetupRabbbitMQConnectionChannel -> setup rabbit mq channel
func SetupRabbbitMQConnectionChannel() (*amqp.Connection, *amqp.Channel) {
//dial
url := fmt.Sprintf("amqp://%s:%s@%s:%s/", constants.USERNAME, constants.PASSWORD, constants.HOST, constants.PORT)
conn, err := amqp.Dial(url)
utils.FailOnError(err, "Failed to connect to RabbitMQ")
ch, err := conn.Channel()
utils.FailOnError(err, "Failed to open a channel")
RabbitChannel = ch
return rabbitConn, RabbitChannel
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment