def handleMessage(self, message): body = message.get_body() try: # Parse the request request = Request(body) except XMLError: # Just return if the request can't be parsed # This throws away the request return # Process the request # If an exception is thrown (other than our RequestErrors), # the message will remain in the queue to be processed again later. # Corrupt data is removed before the exception is raised, so the # request will (hopefully) succeed next time # TODO Add TTL to requests, process max 3 times, or something reply = request.process() # Write the reply to S3 url = S3.uploadFile(request.id + '.xml', reply) # Put the url to the reply in the outqueue m = Message() m.set_body(url) outQueue.write(m)