Skip to content

Commit

Permalink
amqp broker: do not attempt to create a channel if no connection is a…
Browse files Browse the repository at this point in the history
…live
  • Loading branch information
lukasjarosch committed Jul 21, 2020
1 parent d88d85a commit 87aa2d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion broker/amqp/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (b *Broker) Consume(wg *sync.WaitGroup) {
channel, err := b.consumeConn.Channel()
if err != nil {
logger.Warnf("unable to fetch AMQP channel for consumer: %s", err.Error())
time.Sleep(500 * time.Millisecond)
time.Sleep(300 * time.Millisecond)
continue
}

Expand Down
4 changes: 4 additions & 0 deletions broker/amqp/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ func (c *Connection) setConnected(status bool) {
}

func (c *Connection) Channel() (channel *amqp.Channel, err error) {
if !c.IsConnected() {
return nil, fmt.Errorf("amqp connection not alive")
}

c.connMutex.Lock()
defer c.connMutex.Unlock()

Expand Down

0 comments on commit 87aa2d4

Please sign in to comment.