get(() -> {
final MessageDispatcher dispatcher = akkaSystem.dispatchers().lookup("application.dispatcher");
return completeOKWithFuture(CompletableFuture.supplyAsync(() -> {
final Map<String, Object> result = new HashMap<>();
result.put("trackingNumber", trackingNumber);
ArrayList<Map<String, String>> status;
if (this.cache == null) {
status = TrackingCrawler.parseDocument(trackingNumber);
} else {
status = this.cache.readFromCache("tracking." + trackingNumber);
if (status == null) {
status = TrackingCrawler.parseDocument(trackingNumber);
this.cache.writeToCache(
"tracking." + trackingNumber,
status
);
}
}
result.put("status", status);
return result;
}, dispatcher).exceptionally(ex -> {
LOG.error("Something goes wrong", ex);
return new HashMap<>();
}), Jackson.marshaller());
})val `application/json` = awfc("json", HttpCharsets.`UTF-8`, "json")
--
--- You received this message because you are subscribed to the Google Groups "Akka User List" group.Read the docs: http://akka.io/docs/
Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
Search the archives: https://groups.google.com/group/akka-user
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscribe@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.