fix: don't need acks on queue checks (#926)

This commit is contained in:
abelanger5
2024-10-01 20:52:02 -04:00
committed by GitHub
parent c29984305e
commit c3fa2c57f3
5 changed files with 27 additions and 9 deletions

View File

@@ -136,6 +136,9 @@ type Message struct {
// RetryDelay is the delay between retries.
RetryDelay int `json:"retry_delay"`
// Whether the message should immediately expire if it reaches the queue without an active consumer.
ImmediatelyExpire bool `json:"immediately_expire"`
// OtelCarrier is the OpenTelemetry carrier for the task.
OtelCarrier map[string]string `json:"otel_carrier"`
}

View File

@@ -341,9 +341,15 @@ func (t *MessageQueueImpl) startPublishing() func() error {
t.l.Debug().Msgf("publishing msg %s to queue %s", msg.ID, msg.q.Name())
err = pub.PublishWithContext(ctx, "", msg.q.Name(), false, false, amqp.Publishing{
pubMsg := amqp.Publishing{
Body: body,
})
}
if msg.ImmediatelyExpire {
pubMsg.Expiration = "0"
}
err = pub.PublishWithContext(ctx, "", msg.q.Name(), false, false, pubMsg)
// retry failed delivery on the next session
if err != nil {