- @Override
- public Future<RpcResult<Void>> buyCar(BuyCarInput input) {
- log.info("Routed RPC buyCar : generating notification for buying car [{}]", input);
- SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
- CarBoughtBuilder carBoughtBuilder = new CarBoughtBuilder();
- carBoughtBuilder.setCarId(input.getCarId());
- carBoughtBuilder.setPersonId(input.getPersonId());
- notificationProvider.publish(carBoughtBuilder.build());
- futureResult.set(RpcResultBuilder.<Void>success().build());
- return futureResult;
- }
+ return Futures.transform(notificationProvider.offerNotification(new CarBoughtBuilder()
+ .setCarId(input.getCarId())
+ .setPersonId(input.getPersonId())
+ .build()),
+ result -> RpcResultBuilder.success(new BuyCarOutputBuilder().build()).build(),
+ MoreExecutors.directExecutor());
+ }