Skip to content

Commit

Permalink
Merge pull request #29 from IndicoDataSolutions/meg/sqs
Browse files Browse the repository at this point in the history
Update SQSExample.java
  • Loading branch information
goatrocks authored Jul 1, 2021
2 parents f70be94 + 46d5fa9 commit 29def01
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions examples/SQSExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ public static void main(String[] args) throws InterruptedException, IOException
.build();

//request the messages
var messages = sqsClient.receiveMessage(request);
ReceiveMessageResponse messages = sqsClient.receiveMessage(request);
while(true) {
// iterate the messages from SQS
for (Message m : messages.messages()) {
//fetch receipt handle and body
String rh = m.receiptHandle();
JSONObject body = new JSONObject(m.body());
var status = body.getString("status");
var url = body.getString("result_url");
var id = body.getInt("submission_id");
String status = body.getString("status");
String url = body.getString("result_url");
Integer id = body.getInt("submission_id");

System.out.println(body);
if(status.equalsIgnoreCase("COMPLETED")){
if(status.equalsIgnoreCase("COMPLETE")){
System.out.println("Completed: " + id);
//process a completed message
process_result(indicoClient, id, url);
Expand All @@ -73,7 +73,7 @@ public static void main(String[] args) throws InterruptedException, IOException
System.out.print("Submission failed: " + id);
}
//remove message when processed..
var delmsg = DeleteMessageRequest.builder()
DeleteMessageRequest delmsg = DeleteMessageRequest.builder()
.queueUrl(queueUrl)
.receiptHandle(rh)
.build();
Expand All @@ -88,14 +88,15 @@ public static void main(String[] args) throws InterruptedException, IOException

public static void process_result(IndicoClient indicoClient, int id, String url) throws IOException {
System.out.println("get blob....");
var ret_storage_obj = indicoClient.retrieveBlob();
RetrieveBlob ret_storage_obj = indicoClient.retrieveBlob();
ret_storage_obj.url(url);
ret_storage_obj.execute();
System.out.println("update sub....");
var update_sub = indicoClient.updateSubmission();
UpdateSubmission update_sub = indicoClient.updateSubmission();
update_sub.submissionId(id);
update_sub.retrieved(true);
update_sub.execute();

}

public static void submit_workflow(IndicoClient indicoClient){
Expand All @@ -104,7 +105,7 @@ public static void submit_workflow(IndicoClient indicoClient){
String pdf = PDF_LOCATION;
List<String> files = new ArrayList<String>();
files.add(pdf);
var submission = indicoClient.workflowSubmission();
WorkflowSubmission submission = indicoClient.workflowSubmission();
submission.files(files);
submission.workflowId(workflow_id);
submission.execute();
Expand Down

0 comments on commit 29def01

Please sign in to comment.