straightface
straightface
JCHJava Community | Help. Code. Learn.
Created by straightface on 2/3/2024 in #java-help
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
7 replies
JCHJava Community | Help. Code. Learn.
Created by straightface on 4/7/2023 in #java-help
Should I be storing dates in utc?
Lets say I have a venue booking form that requires start date and end date for an event, users can only book full day events. So should I be storing these dates in utc or local time?
10 replies