0
votes

I have two queues SQS a and b and i want to move all messages from one queue to another using Python boto library. This is how I tried to do this:

rs = a.get_messages()
while rs:
  msg = rs[0]
  if not msg:
    break
  b.write(msg)
  a.delete_message(msg)
  rs = a.get_messages()

After I executed that code I see no messages in 'a' (expected) and no messages in b (not expected!). It's probably because I put the same object to the new queue and deleted it. So is there any way to copy message to put the copy to the new queue instead of putting the original object? Or there is something else that I'm doing wrong here?

1
Did you check this github.com/MarcelloLins/AWS-SQS-Fast-copy or is it mandatory for you to use python?error2007s
Yeah, I want something simple, no multi threading, no Microsoft Visual Studio Solution Files, just 10 lines of Python code.mnowotka

1 Answers

0
votes

You'll need to write the message body to a new message and send to queue b.

m = boto.sqs.message.RawMessage(body=msg.get_body())
b.write(m)

trying to send a received message object should raise an exception - check your logs.