Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jaxrs-dev] Guidance for adoption of Reactive APIs

Hi Santiago,

Great questions.

Reactive Streams has a number of sweet spots where it adds a lot of value, and then a number of places where it's useful, but doesn't add as much value. The biggest sweet spot is in messaging, and the first place we are working on in MicroProfile is in handling messaging on top of message brokers, eg Kafka. I don't see any immediate adoption of it in the context of using REST/JAX-RS in MicroProfile, rather, from my point of view, MicroProfile is sorely missing a standard for asynchronous communication between services to complement the existing REST/JAX-RS APIs, so this new Reactive Streams based messaging spec will fill that gap.

That said, once you have a Reactive Streams based messaging API, this opens a number of possibilities with regards to both WebSockets and SSE, where it's often useful to connect these endpoints into some form of messaging API, and Reactive Streams works well to do that.

For streaming output use cases are probably where Reactive Streams is least useful. That's not to say it's not useful, it's just not as useful as in messaging. The advantage of using something like Reactive Streams for the streaming use cases is that it makes it easy to plumb multiple asynchronous streaming sources/sinks together from different technologies - for example, streaming a database blob out to a an HTTP connection. We're still a fair way from getting to that of course - for example there's no real usable solution for talking to a database using asynchronous IO at the moment, of course Oracles ADBA effort will hopefully change that and I have been in communication with the developers of that, Reactive Streams is being adopted there.

A few months ago I wrote a high level overview of where I see Reactive Streams being potentially useful in Jakarta EE. Actually missing from that is mention of JAX-RS, though it's a similar story to the what I wrote about for the Servlet API:

https://developer.lightbend.com/blog/2018-02-06-reactive-streams-ee4j/index.html

Cheers,

James

On Thu, 17 May 2018 at 00:49, Santiago Pericas-Geertsen <santiago.pericasgeertsen@xxxxxxxxxx> wrote:
Hi James,

 Thanks for sharing your work here. 

 Let me start with a quick summary about the JAX-RS discussions we had during 2.1:

 (i) As you know, most JAX-RS use cases involve the return of a single value, an entity. Thus, support for CompletionStage was a natural extension to the API.

 (ii) We discussed the use of Flow in the context of SSE. As I recall, there were two issues with it: (1) we could not depend on JDK 9 (as you discuss in your document) and (2) the resulting API, unsurprisingly, felt a bit “generic”.

 (iii) There are other cases in JAX-RS were reactive streams could be of use (e.g., StreamingOutput) but these are very uncommon.

 Reactive streams are a much better fit in Web servers (Web sockets) and other “lower-level" APIs. In light of this, I’m curious about how you envision adoption of reactive APIs in the current MP stack where REST and JAX-RS are at the core of application development. Is it primarily via a future messaging API? Or some other API?

— Santiago

On May 14, 2018, at 11:20 PM, James Roper <james@xxxxxxxxxxxxx> wrote:

Hi all,

I just wanted to bring to everyones attention a document that we're creating in MicroProfile for guidance in adopting reactive APIs. I understand that JAX-RS 2.1 already has some support for CompletionStage, and that future releases are likely to include support for Reactive Streams (indeed some implementations already do support it).

Although JAX-RS technically isn't under the MicroProfile banner, this document will hopefully be used at least for inspiration, if not adopted in some form, in Jakarta EE. It would be great if some JAX-RS people could review it and comment accordingly.


Cheers,

James

--
James Roper
Senior Octonaut

Lightbend – Build reactive apps!
Twitter: @jroper

_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev

_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev


--
James Roper
Senior Octonaut

Lightbend – Build reactive apps!
Twitter: @jroper


Back to the top