Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docproc does not return a jsonifyable object, therefore the lambda fails and will retry #14

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/asyncproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def processItems(qUrl, snsTopic, snsRole):
limitException = e

if(hitLimit):
raise limitException
raise limitException()

return totalMessages, jc

Expand Down
17 changes: 11 additions & 6 deletions src/docproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ def postMessage(client, qUrl, jsonMessage):

message = json.dumps(jsonMessage)

client.send_message(
response = client.send_message(
QueueUrl=qUrl,
MessageBody=message
)

print("Submitted message to queue: {}".format(message))
return response

def processRequest(request):

Expand All @@ -34,15 +35,16 @@ def processRequest(request):
qUrl = request['asyncQueueUrl']

if(qUrl):
features = ["Text", "Forms", "Tables"]
features = ["Text", "Forms", "Tables"]

jsonMessage = { 'documentId' : documentId,
"features" : features,
'bucketName': bucketName,
'objectName' : objectName }

client = AwsHelper().getClient('sqs')
postMessage(client, qUrl, jsonMessage)
response = postMessage(client, qUrl, jsonMessage)
return response

output = "Completed routing for documentId: {}, object: {}/{}".format(documentId, bucketName, objectName)

Expand Down Expand Up @@ -76,7 +78,8 @@ def processRecord(record, syncQueueUrl, asyncQueueUrl):
request['syncQueueUrl'] = syncQueueUrl
request['asyncQueueUrl'] = asyncQueueUrl

processRequest(request)
response = processRequest(request)
return response

def lambda_handler(event, context):

Expand All @@ -94,8 +97,10 @@ def lambda_handler(event, context):

if("eventName" in record and record["eventName"] == "INSERT"):
if("dynamodb" in record and record["dynamodb"] and "NewImage" in record["dynamodb"]):
processRecord(record, syncQueueUrl, asyncQueueUrl)

response = processRecord(record, syncQueueUrl, asyncQueueUrl)
return {
'message': json.dumps(response)
}
except Exception as e:
print("Faild to process record. Exception: {}".format(e))

Expand Down
Binary file added src/helper.pyc
Binary file not shown.