Skip to content

Instantly share code, notes, and snippets.

@AstroTom
Created April 6, 2021 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AstroTom/8461fa9930d07d92c117229c606ac006 to your computer and use it in GitHub Desktop.
Save AstroTom/8461fa9930d07d92c117229c606ac006 to your computer and use it in GitHub Desktop.
Send to SQS a few treks at a time, then wait till Q is empty to send again
#
# send to q a few treks at a time, then wait till Q is empty to send again
#
AWSACCNT=123456789012
Q=https://sqs.eu-west-1.amazonaws.com/$AWSACCNT/prd_navigation_q
Q=https://sqs.eu-west-1.amazonaws.com/$AWSACCNT/stg_navigation_q
QMAX=29 # do not fill Q with more than these
QMAX=5
#set -x
count=1
while read TREK
do
aws sqs send-message --queue-url $Q --message-body $TREK
echo sent message number $((count++))
QATTR=ApproximateNumberOfMessages # no. of msgs
QATTR=ApproximateNumberOfMessagesNotVisible # no. of msgs inflight
while (( $QMAX <= $(aws sqs get-queue-attributes --queue-url $Q --attribute-names $QATTR --output text --query Attributes.$QATTR) ))
do
echo sleeping...
sleep 2
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment