Skip to content

Commit

Permalink
Avoid getting updates for non-routable items (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfinocchiaro authored Dec 14, 2024
1 parent 08f662f commit 9b60c71
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,17 @@ public void process(ConsumerRecord<K, V> record) throws ValueException {
log.atDebug().log(() -> "Mapped Kafka record");

Set<SubscribedItem> routables = mappedRecord.route(subscribedItems);

log.atDebug().log(() -> "Filtering updates");
Map<String, String> updates = mappedRecord.fieldsMap();

for (SubscribedItem sub : routables) {
log.atDebug().log(() -> "Sending updates: %s".formatted(updates));
listener.smartUpdate(sub.itemHandle(), updates, false);
if (routables.size() > 0) {
log.atDebug().log(() -> "Filtering updates");
Map<String, String> updates = mappedRecord.fieldsMap();

log.atInfo().log("Routing record to {} items", routables.size());
for (SubscribedItem sub : routables) {
log.atDebug().log(() -> "Sending updates: %s".formatted(updates));
listener.smartUpdate(sub.itemHandle(), updates, false);
}
} else {
log.atInfo().log("No routable items found");
}
}
}
Expand Down

0 comments on commit 9b60c71

Please sign in to comment.