Reputation: 169
I have some problem with firing RestController when I want to fire it from a Thread. I'm trying to send a request to RestController from my thread but I don't get any response from the controller when my restTemplate is executing destination URL. RestController isn't even executed. It is working as expected only if I'm sending a request from ui.access->rest.sendRequest()
, but then my application must wait for the end of the request anyway.
I'm working with Vaadin 14. I created a thread with a run method like this:
CompletableFuture<Long> nonBlocking = CompletableFuture.supplyAsync(() -> restTemp.getForObject("http://localhost:4240/Servis/api/address",
Long.class));
nonBlocking.thenAccept(s -> {
if (s != null) {
ui.access(() -> Notification.open("long is not null"));
} else {
ui.access(() -> Notification.open("long is null"));
}
});
nonBlocking.get();
But my code from the rest controller is still not executed.
Upvotes: 1
Views: 290
Reputation: 169
I make it work as expected when i replaced RestTemplate with WebClient
Upvotes: 1