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

Allow asynchronous web services #9

Closed
marcban opened this issue Dec 8, 2017 · 3 comments
Closed

Allow asynchronous web services #9

marcban opened this issue Dec 8, 2017 · 3 comments
Assignees

Comments

@marcban
Copy link

marcban commented Dec 8, 2017

For the moment, all the services I wrote had the "Blocking" annotation.

It works pretty well, but its is not an ideal solution for an asynchronous framework like vertx.

It would be interesting to have a way of writing asynchronous methods, either with the Jax-RS 2.0 AsyncResponse (which is quite complex) or by letting the methods have a way of calling a "resume" method with the result as a parameter.

@drejc
Copy link
Member

drejc commented Dec 8, 2017

I think this could be achieved using the Vert.X message bus system ... which I already plan to make easier to use with annotations ... combining those two you could achieve this.

@drejc
Copy link
Member

drejc commented Feb 7, 2018

OK ... I have released a test version with Async execution ... should be up in about 30mins

<dependency>
  <groupId>com.zandero</groupId>
  <artifactId>rest.vertx</artifactId>
  <version>0.8.1-RC.1</version>
</dependency>

If a REST method returns a Future than a handler waits for the future to finish ... and returns the desired response.
The writer is determined according the future.result() type ...

For instance:

@GET
@Path("async/{time}")
@ResponseWriter(GenericResponseWriter.class)
public Future<String> async(@Context Vertx vertx, @PathParam("time") int time) {
	Future<String> future = Future.future();
	slowService.async(vertx, future, time);
	return future;
}

Please give it a spin ...

@marcban
Copy link
Author

marcban commented Feb 7, 2018

thank you ! I will try to test it before the end of the week

@drejc drejc closed this as completed Feb 9, 2018
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

2 participants