Skip to content

Commit

Permalink
fixed sns publish msg id
Browse files Browse the repository at this point in the history
  • Loading branch information
hirenkp2000 committed Sep 10, 2024
1 parent 4dbb05d commit 023c8ac
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,8 @@ public void publishTransactions(final PubConfig pubCfg, final Subscription sub,
final int msgLength = msg.length();
final Map<String, MessageAttributeValue> msgAttrMap = populateMessageAttributeMap(txnData, sub, spaceId);

// Prepare PublishBatchEntry for current message
final PublishBatchRequestEntry batchEntry = PublishBatchRequestEntry.builder()
.message(msg)
.messageAttributes(msgAttrMap)
.id(MSG_ID_PREFIX + batchEntryCounter)
.build();

// publish batch if payload limit reached
if (msgLength+aggrBatchPayloadSize > MAX_ALLOWED_PAYLOAD_SIZE && batchEntries.size()>0) {
// publish accumulated batch if payload limit reached
if (msgLength+aggrBatchPayloadSize > MAX_ALLOWED_PAYLOAD_SIZE && !batchEntries.isEmpty()) {
// publish current batch
publishBatchEntriesAndCheckResult(batchEntries, snsTopic, snsClient, txnList, subId, publishedRecCnt, MSG_ID_PREFIX, pubCfg, pubDTO);
// update batch variables
Expand All @@ -81,6 +74,12 @@ public void publishTransactions(final PubConfig pubCfg, final Subscription sub,
batchEntryCounter = 0;
}

// Prepare PublishBatchEntry for current message
final PublishBatchRequestEntry batchEntry = PublishBatchRequestEntry.builder()
.message(msg)
.messageAttributes(msgAttrMap)
.id(MSG_ID_PREFIX + batchEntryCounter)
.build();
// add current message to the batch
batchEntries.add(batchEntry);
aggrBatchPayloadSize += msgLength;
Expand Down

0 comments on commit 023c8ac

Please sign in to comment.