Skip to content

Instantly share code, notes, and snippets.

@marcosabel
Last active July 8, 2018 10:13
Show Gist options
  • Save marcosabel/ba75f534bc2c785dbaccd48444f51d23 to your computer and use it in GitHub Desktop.
Save marcosabel/ba75f534bc2c785dbaccd48444f51d23 to your computer and use it in GitHub Desktop.
// Snippet of code used to evict invoices cache when mqtt messages arrive. We assume we have an mqttComponent and
// an invoiceService correctly defined in the current scope
mqttComponent.subscribeToTopicWithEmptyPayload("caches/invoices/+/evict",evictInvoiceCache(),1);
// ...
private Function<String,Void> evictInvoiceCache() {
return topic->{
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher(topic);
matcher.find();
invoiceService.evictInvoicesCache(matcher.group());
return null;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment