When I try to publish about a 1000 messages to a SQS FIFO queue (in a goroutine) using the SQS SDK, I get this error - operation error SQS: SendMessage, failed to get rate limit token, retry quota exceeded, 2 available, 5 requested
This is how I publish:
wg := sync.WaitGroup{}
messages := []string{}
for _, message := range messages {
wg.Add(1)
go func() {
defer wg.Done()
//publish to SQS
}()
}
wg.Wait()
I try to fix by adding these to the aws config, following this suggestion - https://github.com/aws/aws-sdk-go-v2/issues/543#issuecomment-620124268:
"github.com/aws/aws-sdk-go-v2/config"
type NoOpRateLimit struct{}
func (NoOpRateLimit) AddTokens(uint) error { return nil }
func (NoOpRateLimit) GetToken(context.Context, uint) (func() error, error) {
return noOpToken, nil
}
func noOpToken() error { return nil }
return config.LoadDefaultConfig(
ctx,
config.WithRetryer(func() aws.Retryer {
return retry.NewStandard(func(options *retry.StandardOptions) {
options.RateLimiter = NoOpRateLimit{}
})
}),
)
But the failure rate even increased. How can I fix this please?