-
Notifications
You must be signed in to change notification settings - Fork 0
/
deliveryEx.go
32 lines (26 loc) · 934 Bytes
/
deliveryEx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package rabbit
import (
"fmt"
"github.com/streadway/amqp"
)
type envelope struct {
*amqp.Delivery
}
func (m *envelope) maybeAckMessage(ack bool, log *rabbitLogger) {
if ack {
err := m.Ack(false)
checkErrorLight(err, fmt.Sprintf("MessageId=%s, CorrelationId=%s, could not ack the message, it will be eventually requeued", m.MessageId, m.CorrelationId), log)
}
}
func (m *envelope) maybeRequeueMessage(ack bool, log *rabbitLogger) {
if ack {
err := m.Nack(false, true)
checkErrorLight(err, fmt.Sprintf("MessageId=%s, CorrelationId=%s, could not nack the message, it will be eventually requeued", m.MessageId, m.CorrelationId), log)
}
}
func (m *envelope) maybeRejectMessage(ack bool, log *rabbitLogger) {
if ack {
err := m.Nack(false, false)
checkErrorLight(err, fmt.Sprintf("MessageId=%s, CorrelationId=%s, could not nack the message, it will be eventually requeued", m.MessageId, m.CorrelationId), log)
}
}