amazonica
amazonica copied to clipboard
using different Amazon*Clients for multhreading
Hello,
I have an application using SQS, and i'd like to consume/process it from different threads ... but after the msgs are in flight, the other threads cant fetch new msgs
Looking at the docs ive found:
Note: The first function called (for each distinct AWS service namespace, e.g. amazonica.aws.ec2)
creates an Amazon*Client, which is effectively cached via memoization. Therefore, if you explicitly pass different credentials maps to different functions, you will effectively have different Clients.
I guess this is the reason behind it.. is there a way to use individual clients (or another proper solution) so each thread can process its own batch (of 10 msgs) ?
thanks!
you can consume from the queue inside multiple (future....)
Not sure if I got it right ... lets suppose I have 100 msgs (0 in-flight), and I'd like to print them all this should do the trick?
(dotimes [_ 10]
(future
(let [payload (sqs/receive-message aws-cfg
{:max-number-of-messages 10
:queue-url queue-url})]
(prn payload))))
Because right now the first thread print 10 msgs and the other 9 receive an empty list (like there are no msgs in the queue)
thank you for the fast response!
you may want to try adding wait-time-seconds
to your receive-message
calls