Browse Source

реконнект каждые 5 секунд

pull/62/head
Fedor Ortyanov 4 years ago
parent
commit
cf68d948b0
6 changed files with 8 additions and 12 deletions
  1. +1
    -1
      README.md
  2. +2
    -4
      channel.go
  3. +2
    -4
      consume.go
  4. +1
    -1
      examples/consumer/main.go
  5. +1
    -1
      examples/logger/main.go
  6. +1
    -1
      examples/publisher/main.go

+ 1
- 1
README.md View File

@ -24,7 +24,7 @@ The goal with `go-rabbitmq` is to still provide most all of the nitty-gritty fun
Inside a Go module:
```bash
go get github.com/wagslane/go-rabbitmq
go get github.com/fortyanov/go-rabbitmq
```
## 🚀 Quick Start Consumer


+ 2
- 4
channel.go View File

@ -76,11 +76,9 @@ func (chManager *channelManager) startNotifyCancelOrClosed() {
// reconnectWithBackoff continuously attempts to reconnect with an
// exponential backoff strategy
func (chManager *channelManager) reconnectWithBackoff() {
backoffTime := time.Second
for {
chManager.logger.Printf("waiting %s seconds to attempt to reconnect to amqp server", backoffTime)
time.Sleep(backoffTime)
backoffTime *= 2
chManager.logger.Printf("waiting 5 seconds to attempt to reconnect to amqp server")
time.Sleep(5 * time.Second)
err := chManager.reconnect()
if err != nil {
chManager.logger.Printf("error reconnecting to amqp server: %v", err)


+ 2
- 4
consume.go View File

@ -153,11 +153,9 @@ func (consumer Consumer) startGoroutinesWithRetries(
routingKeys []string,
consumeOptions ConsumeOptions,
) {
backoffTime := time.Second
for {
consumer.logger.Printf("waiting %s seconds to attempt to start consumer goroutines", backoffTime)
time.Sleep(backoffTime)
backoffTime *= 2
consumer.logger.Printf("waiting 5 seconds to attempt to start consumer goroutines")
time.Sleep(5 * time.Second)
err := consumer.startGoroutines(
handler,
queue,


+ 1
- 1
examples/consumer/main.go View File

@ -7,8 +7,8 @@ import (
"os/signal"
"syscall"
rabbitmq "github.com/fortyanov/go-rabbitmq"
amqp "github.com/rabbitmq/amqp091-go"
rabbitmq "github.com/wagslane/go-rabbitmq"
)
var consumerName = "example"


+ 1
- 1
examples/logger/main.go View File

@ -3,8 +3,8 @@ package main
import (
"log"
rabbitmq "github.com/fortyanov/go-rabbitmq"
amqp "github.com/rabbitmq/amqp091-go"
rabbitmq "github.com/wagslane/go-rabbitmq"
)
// customLogger is used in WithPublisherOptionsLogger to create a custom logger.


+ 1
- 1
examples/publisher/main.go View File

@ -8,8 +8,8 @@ import (
"syscall"
"time"
rabbitmq "github.com/fortyanov/go-rabbitmq"
amqp "github.com/rabbitmq/amqp091-go"
rabbitmq "github.com/wagslane/go-rabbitmq"
)
func main() {


Loading…
Cancel
Save