eclipse-ee4j / eclipse-ee4j/jersey

Repalcement of EJB @Asynchronous and @Suspend AysncResponse

Open
#5,099 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

In the traditional Jaxrs2.x (Java EE7/8), [there are several approaches](https://github.com/hantsy/ee8-sandbox/tree/master/jaxrs-async/src/main/java/com/hantsylabs/example/ee8/jaxrs) to support async response in Jaxrs.

We can use ejb `@Asychronous` and `@Suspend` AsyncResponse like this.

```java
@Path("ejb")
@Stateless
public class EjbAsyncResource {

@Inject
Logger LOG;

@GET
@Asynchronous // from ejb
public void getAsync(final @Suspended AsyncResponse res) {

//perform long run operations.
try {
LOG.log(Level.INFO, " execute long run task in EjbAsyncResource");
Thread.sleep(500);
} catch (InterruptedException ex) {
LOG.log(Level.SEVERE, "error :" +ex.getMessage());
}

res.resume(Response.ok("Asynchronus EJB resource").build());
}

}
```

And as planned in the future Jakarta EE specs, the EJB will be replaced with new CDI compatible replacement.

Currently, there is a new `@Asynchronous` added in the concurrency 3.0 spec. But it seems this annotation can not replace the ejb `@Asynchronous` in the above case.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the linked JAX-RS async example and comparing its EJB @Asynchronous and @Suspended AsyncResponse usage with the Concurrency 3.0 @Asynchronous annotation mentioned in the issue. Determine the intended Jakarta EE replacement and define a concrete API or specification outcome before implementation; the issue is done only when that replacement is clearly supported or documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.