Skip to content

Instantly share code, notes, and snippets.

@maxant
Created December 30, 2014 21:02
Show Gist options
  • Save maxant/f527374c8e6fbcf57d26 to your computer and use it in GitHub Desktop.
Save maxant/f527374c8e6fbcf57d26 to your computer and use it in GitHub Desktop.
Handling the end of persistence
persistSales(sales, t -> {
if(t != null){
LOGGER.error("failed to persist sales: " + sales, t);
}else{
LOGGER.info("persisting completed, notifying involved parties...");
sales.stream().forEach(sale -> {
if (sale.getBuyer().listener != null)
sale.getBuyer().listener.onEvent(EventType.PURCHASE, sale);
if (sale.getSeller().listener != null)
sale.getSeller().listener.onEvent(EventType.SALE, sale);
});
...
}
listener.onEvent(EventType.STOPPED, null);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment