Created
April 6, 2021 11:51
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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