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

Kinesis putrecords sampler #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Kinesis putrecords sampler #4

wants to merge 2 commits into from

Conversation

samarr
Copy link

@samarr samarr commented Jan 18, 2022

Have created a Kinesis put records sampler as per the request - #3. Please check and share any feedback you have.

@kishaningithub
Copy link

@JoseLuisSR If you don't have any concerns, can you kindly merge this?

@kishaningithub
Copy link

@JoseLuisSR Bumping this up

try {
putRecordsRequestEntryList.add(PutRecordsRequestEntry.builder()
.data(SdkBytes.fromByteArray(String.valueOf(jsonArray.get(i)).getBytes(StandardCharsets.UTF_8)))
.partitionKey(context.getParameter(KINESIS_PARTITION_KEY) + "-" + i).build());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each record could specify the Data, ExplicitHashKey, and Partition Key.
Could you please get these fields from the JSON and use them to build PutReecordsRequestEntry.

JSONArray jsonArray = new JSONArray(tempPayload);
List<PutRecordsRequestEntry> putRecordsRequestEntryList = new ArrayList<>();
PutRecordsRequest putRecordsRequest = null;
for (int i = 0; i < jsonArray.length(); i++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The limit of records is 500.
Please add validation to not exceed this limit.

} catch (JSONException e) {
e.printStackTrace();
}
putRecordsRequest = PutRecordsRequest.builder()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you are building PutRecordRequest for each record in the array.
I guess is better to create PutRecordRequest once with the List<PutRecordsRequestEntry and streamName.

Copy link
Owner

@JoseLuisSR JoseLuisSR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @samarr

Thank you to send it PR.

I agree with you to create another Java Sampler to produce put records on Kinesis Data Stream.

I suggested some changes to improve the solution.

Please let me know if you have doubts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants