Java V2: Added the follow for sending and receiving messages in batches for SQS#7508
Java V2: Added the follow for sending and receiving messages in batches for SQS#7508tejasgn1 wants to merge 4 commits into
Conversation
| } catch (IOException e) { | ||
| logger.log(Level.SEVERE, "Error reading file", e); | ||
| } finally { | ||
| // Clean up by deleting the queue |
|
|
||
| import java.util.*; | ||
| import java.util.stream.Stream; | ||
|
|
There was a problem hiding this comment.
Look at our tests for Java in the Java Standards doc.
https://github.com/awsdocs/aws-doc-sdk-examples/wiki/Java-code-example-standards
For example - use of @testinstance and @TestMethodOrder JUNT annotations
There was a problem hiding this comment.
Hi Scott, I have now updated according to the Java Standards doc and have also added periods in comments.
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.logging.Level; |
There was a problem hiding this comment.
For logging, use Slf4J with a Log4j2 implementation.
There was a problem hiding this comment.
Hi @tkhill-AWS , I have updated it to slf4j and accordingly made code changes.
| rootLogger.setLevel(Level.WARNING); | ||
| } | ||
| private static final SqsClient sqsClient = SqsClient.builder() | ||
| .region(Region.US_WEST_2) |
There was a problem hiding this comment.
This client will try to use a queue that's in the us-west-2 region, but if the queue created in the test uses a different region, the queue won't be found and an error will result. This is what happened to me. So, either specify the the region in both places, or let the user's config determine the region (that's my preference).
There was a problem hiding this comment.
Got it. I understood. I have removed the region in the latest commit.
| try { | ||
| // Read the lines from this Java file. | ||
| Path projectRoot = Paths.get(System.getProperty("user.dir")); | ||
| Path filePath = projectRoot.resolve("src/main/java/com/example/sqs/SendRecvBatch.java"); |
There was a problem hiding this comment.
Using user.dir is not recommended because it's unreliable depending on where the process was started.
Moreover, this failed for me:
Path filePath = projectRoot.resolve("src/main/java/com/example/sqs/SendRecvBatch.java");
Because:
-
projectRootvariable resolved to:/Users/tkhill/IdeaProjects/aws-doc-sdk-examples -
filePathvariable resolved to:/Users/tkhill/IdeaProjects/aws-doc-sdk-examples/src/main/java/com/example/sqs/SendRecvBatch.java
But should have resolved to: /Users/tkhill/IdeaProjects/aws-doc-sdk-examples/javav2/example_code/sqs/src/main/java/com/example/sqs/SendRecvBatch.java (Note the missing javav2/example_code/sqs path elements).
There was a problem hiding this comment.
Oh got it. I was using the relative path. Instead, I should have used the absolute path of the file. Do I fix this by pushing a new commit?
|
Closing as Todd has worked to get this into another PR |
This PR handles the Java follow for sending and receiving messages in batches for Amazon SQS.
CDD build: link
SIM Ticket: link
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.