Skip to content

Commit

Permalink
MAINT-2528 Improve log message when traceability data is chunked
Browse files Browse the repository at this point in the history
  • Loading branch information
pgwilliams committed Mar 27, 2024
1 parent bc0c69b commit b7ceb1f
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.snomed.snowstorm.core.data.services.traceability;

import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -41,13 +43,14 @@ public void accept(Activity activity) {
*/
void sendInBatches(Activity activity) {
int changeListSize = activity.getChanges().size();
logger.info("Number of changes (concept activities) is {} and is larger than max ({}).", changeListSize, maxConceptActiviesPerMessage );

for (List<Activity.ConceptActivity> conceptActivities : Iterables.partition(activity.getChanges(), maxConceptActiviesPerMessage)) {
Activity activityChunk = new Activity(activity.getUserId(), activity.getBranchPath(),
activity.getCommitTimestamp(), activity.getSourceBranch(), activity.getActivityType());
activityChunk.setChanges(conceptActivities);
jmsTemplate.convertAndSend(jmsQueuePrefix + ".traceability", activityChunk);
}
List<List<Activity.ConceptActivity>> chunkedList = Lists.partition(activity.getChanges(), maxConceptActiviesPerMessage);
logger.info("Chunking {} concept activities into {} batches (of max size {})", changeListSize, chunkedList.size(), maxConceptActiviesPerMessage);

for (List<Activity.ConceptActivity> conceptActivities : chunkedList) {
Activity activityChunk = new Activity(activity.getUserId(), activity.getBranchPath(),
activity.getCommitTimestamp(), activity.getSourceBranch(), activity.getActivityType());
activityChunk.setChanges(conceptActivities);
jmsTemplate.convertAndSend(jmsQueuePrefix + ".traceability", activityChunk);
}
}
}

0 comments on commit b7ceb1f

Please sign in to comment.