-
Notifications
You must be signed in to change notification settings - Fork 8
Promise.thenMap
The method Promise.thenMap
converts one type of promise into another.
Let's say for example you are storing data into Cassandra.
You want to convert a promise that returns a Cassandra ResultSet
into a promise that returns a Boolean
.
final Promise<ResultSet> resultSetPromise = Promises.<ResultSet>promise();
final Promise<Boolean> promise = resultSetPromise
.thenMap(ResultSet::wasApplied) // <-------------- see thenMap
.catchError((error) -> {
if (error instanceof DriverException) {
logger.error("Error " + message, error);
errorCount.incrementAndGet();
}
});
/* registerCallback is from Reakt Guava Bridge
It converts ListableFutures into Reakt promises (to/fro).
*/
registerCallback(resultSetFuture, resultSetPromise);
Here is a simpler example that turns an Employee Promise into a Sheep Promise.
Promise<Employee> employeePromise = Promises.<Employee>promise();
Promise<Sheep> sheepPromise = employeePromise
.thenMap(employee1 -> new Sheep(employee1.id));
employeeService.lookupEmployee("id123", employeePromise);
Java Promises
- Promise
- Promise then*() and catchError()
- Promise thenMap()
- Promise all()
- Promise any()
- Blocking Promise
- Invokable Promise
- Reactor Replay Promises
Reactor, Stream, Results
- QBit Reactive Microservices
- Reakt Reactive Java
- Reakt Guava Bridge
- QBit Extensions
- Elekt Consul Leadership election
- Elekt Leadership election
- Reactive Microservices
What is Microservices Architecture?
QBit Java Micorservices lib tutorials
The Java microservice lib. QBit is a reactive programming lib for building microservices - JSON, HTTP, WebSocket, and REST. QBit uses reactive programming to build elastic REST, and WebSockets based cloud friendly, web services. SOA evolved for mobile and cloud. ServiceDiscovery, Health, reactive StatService, events, Java idiomatic reactive programming for Microservices.
Reactive Programming, Java Microservices, Rick Hightower
Java Microservices Architecture
[Microservice Service Discovery with Consul] (http://www.mammatustech.com/Microservice-Service-Discovery-with-Consul)
Microservices Service Discovery Tutorial with Consul
[Reactive Microservices] (http://www.mammatustech.com/reactive-microservices)
[High Speed Microservices] (http://www.mammatustech.com/high-speed-microservices)
Reactive Microservices Tutorial, using the Reactor
QBit is mentioned in the Restlet blog
All code is written using JetBrains Idea - the best IDE ever!
Kafka training, Kafka consulting, Cassandra training, Cassandra consulting, Spark training, Spark consulting
Java Promises
- Promise
- Promise then*() and catchError()
- Promise thenMap()
- Promise all()
- Promise any()
- Blocking Promise
- Invokable Promise
- Reactor Replay Promises
Callback, and async Results
Reactor, Stream and Stream Result
Expected & Circuit Breaker
Scala Akka and Reakt