Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit 4ee5455

Browse files
author
Dries Pauwels
committed
republish channel only created in case of dead-letter-box config
1 parent 5023d47 commit 4ee5455

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

consumer/consumer.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,19 @@ func (c *Consumer) Consume() {
3636
}
3737
c.InfLogger.Println("Succeeded registering consumer.")
3838

39-
sendCh, err := c.Connection.Channel()
40-
if err != nil {
41-
c.ErrLogger.Println("Could not open channel to republish failed jobs %s", err)
39+
var sendCh *amqp.Channel
40+
41+
if c.DeadLetter {
42+
var err error
43+
sendCh, err = c.Connection.Channel()
44+
if err != nil {
45+
c.ErrLogger.Println("Could not open channel to republish failed jobs %s", err)
46+
}
47+
defer sendCh.Close()
4248
}
4349

4450
defer c.Connection.Close()
4551
defer c.Channel.Close()
46-
defer sendCh.Close()
4752

4853
forever := make(chan bool)
4954

0 commit comments

Comments
 (0)