more
This commit is contained in:
+6
-1
@@ -60,7 +60,12 @@ func (p *rabbitPublisher) Publish(exchange, routingKey string, body []byte) erro
|
||||
return err
|
||||
}
|
||||
}
|
||||
err := p.ch.PublishWithContext(context.Background(), exchange, routingKey, false, false,
|
||||
// Bound the publish so a half-open/black-holed connection can't wedge the
|
||||
// outbox relay indefinitely; on timeout the error path resets and the relay
|
||||
// retries on its next tick.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
err := p.ch.PublishWithContext(ctx, exchange, routingKey, false, false,
|
||||
amqp.Publishing{ContentType: "application/json", Body: body})
|
||||
if err != nil {
|
||||
p.reset() // force a reconnect on the next attempt
|
||||
|
||||
Reference in New Issue
Block a user