N
N
Nikita2017-05-15 10:39:49
Java
Nikita, 2017-05-15 10:39:49

Java: How to make work with asynchronous service synchronous?

Good day to all.
There is a development, an intermediate server that receives requests and redirects them to other services.
With one of the services, work goes through sockets and is asynchronous, i.e. the request is written to the socket, then the response is expected. However, work with the server itself should be through synchronous requests. What is the best way to solve the problem?
So far, I've implemented it simply through an endless loop of listening to the socket, and interrupting it when a response is received, but it seems to me that this is not the best option, since a high load on the server is expected.
I looked towards Future and Callable, but have not yet figured out what's what.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question