RMI calls in CompletableFuture stream

is it safe to call rmi service using CompletableFuture like so
Registry registry = null;
try {
// Locate the RMI registry and obtain a reference to the remote object
registry = LocateRegistry.getRegistry("your_server_hostname", 1099);
} catch (Exception e) {
e.printStackTrace();
}
PersonService personService = (PersonService) registry.lookup("PersonService");
// Use CompletableFuture to perform RMI calls in parallel
List<Person> lastNameFutures = personList.stream()
.map(person -> CompletableFuture.supplyAsync(() -> {
person.setCompletableName(personService.getLastName(person)
return person;
}
), executorService))
.collect(Collectors.toList());
Registry registry = null;
try {
// Locate the RMI registry and obtain a reference to the remote object
registry = LocateRegistry.getRegistry("your_server_hostname", 1099);
} catch (Exception e) {
e.printStackTrace();
}
PersonService personService = (PersonService) registry.lookup("PersonService");
// Use CompletableFuture to perform RMI calls in parallel
List<Person> lastNameFutures = personList.stream()
.map(person -> CompletableFuture.supplyAsync(() -> {
person.setCompletableName(personService.getLastName(person)
return person;
}
), executorService))
.collect(Collectors.toList());
Notice i am mutating person object and saving future in Person
4 Replies
JavaBot
JavaBot10mo ago
This post has been reserved for your question.
Hey @straightface! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here. 💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
straightface
straightfaceOP10mo ago
anybody?
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
JavaBot
JavaBot10mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server