Skip to content

Commit

Permalink
Delete SQS message if unmarshalling fails (#504)
Browse files Browse the repository at this point in the history
* Delete SQS message if unmarshalling fails

* Fix failing unit test
  • Loading branch information
bharat-p authored and RichardKnop committed Dec 22, 2019
1 parent 7a7f434 commit 93dc9ee
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions v1/brokers/sqs/sqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ func (b *Broker) consumeOne(delivery *awssqs.ReceiveMessageOutput, taskProcessor
decoder.UseNumber()
if err := decoder.Decode(sig); err != nil {
log.ERROR.Printf("unmarshal error. the delivery is %v", delivery)
// if the unmarshal fails, remove the delivery from the queue
if delErr := b.deleteOne(delivery); delErr != nil {
log.ERROR.Printf("error when deleting the delivery. delivery is %v, Error=%s", delivery, delErr)
}
return err
}
if delivery.Messages[0].ReceiptHandle != nil {
Expand Down

0 comments on commit 93dc9ee

Please sign in to comment.