Skip to content

Commit

Permalink
Merge pull request #161 from sunmi-OS/feature/v1.5-patch
Browse files Browse the repository at this point in the history
Feature/v1.5 patch
  • Loading branch information
luduoxin authored Mar 22, 2024
2 parents 1973c01 + 86dfa86 commit 25f252c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rabbitmq/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ func connRbbitmq() error {
vhost := viper.GetEnvConfig("rabbitmq.vhost")
user := url.QueryEscape(viper.GetEnvConfig("rabbitmq.user"))
password := url.QueryEscape(viper.GetEnvConfig("rabbitmq.password"))
scheme := "amqp"
enableTLS := viper.GetEnvConfigBool("rabbitmq.enableTLS")
if enableTLS {
scheme = "amqps"
}

amqpcoinf := amqp.Config{
amqpConfig := amqp.Config{
Vhost: vhost,
Heartbeat: 10 * time.Second,
Locale: "en_US",
}

conn, err := amqp.DialConfig(fmt.Sprintf("amqp://%s:%s@%s:%s/", user, password, host, port), amqpcoinf)
conn, err := amqp.DialConfig(fmt.Sprintf("%s://%s:%s@%s:%s/", scheme, user, password, host, port), amqpConfig)
if err != nil {
return err
}
Expand Down

0 comments on commit 25f252c

Please sign in to comment.