Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Asynchronous Requests #141

Open
AlexanderNeumann opened this issue Jun 14, 2022 · 0 comments
Open

[ENH] Asynchronous Requests #141

AlexanderNeumann opened this issue Jun 14, 2022 · 0 comments

Comments

@AlexanderNeumann
Copy link
Member

  1. Motivation - Since we have a peer to peer microservice infrastructure, several Web requests stacked together lead into long waiting times.

Request processing on the server works by default in a synchronous processing mode, which means that a client connection of a request is processed in a single I/O container thread

https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/async.html

  1. Specification - I played around with it a little bit and can confirm that requests are handled synchronously. We should enable async functionality at the webconnector. I also tried to use described functions:
@GET
    public void asyncGet(@Suspended final AsyncResponse asyncResponse) {
 
        new Thread(new Runnable() {
            @Override
            public void run() {
                String result = veryExpensiveOperation();
                asyncResponse.resume(result);
            }
 
            private String veryExpensiveOperation() {
                // ... very expensive operation
            }
        }).start();
    }

But they lead to 500 errors with no logs. Although using jersey 2.35 it won't work.
Could be worth exchanging the HTTP Server with a modern solution?
https://github.com/rwth-acis/las2peer/blob/master/webconnector/src/main/java/i5/las2peer/connectors/webConnector/WebConnector.java#L421-L425
and
https://github.com/rwth-acis/las2peer/blob/master/webconnector/src/main/java/i5/las2peer/connectors/webConnector/WebConnector.java#L455-L460

At least it worked when I tried the GrizzlyHttpServerFactory.createHttpServer(...), but this would need some small adjustments

  1. Finalised state - Asynchronous functions as described in 2 should work.

@lakhoune @fxjordan @FBasels @phil-cd does one of you know a better HTTP Server that we should use? At the moment the WebConnector uses JdkHttpServerFactory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant