Skip to content

savoirtech/apache-cxf-reactive-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apache CXF Reactive Demo

This demo project showcases building reactive REST endpoints using Apache CXF, RxJava, andJAX-RS with Spring Boot. It illustrates returning reactive types (Single, Flowable) and streaming responses using JAX-RS StreamingOutput.


Build

mvn clean install

Run

mvn spring-boot:run

API Endpoints

All endpoints are under the base path: http://localhost:8080/api/greet

  1. GET /api/greet/{name}

    Description: Returns a simple greeting message wrapped in an RxJava Single. Produces: application/json Example:

curl -N http://localhost:8080/api/greet/John

Response:

"Hello, John!"
  1. GET /api/greet/stream

    Description: Streams plain text lines (one, two, three) as a JAX-RS StreamingOutput. Produces: text/plain Example:

curl -N http://localhost:8080/api/greet/stream

Response:

one
two
three
  1. GET /api/greet/stream-flowable

    Description: Streams JSON array of greeting objects (Greeting POJO) using RxJava Flowable wrapped inside StreamingOutput. Produces: application/json Example:

curl -N http://localhost:8080/api/greet/stream-flowable

Response:

[
  {"message":"Hello one"},
  {"message":"Hello two"},
  {"message":"Hello three"}
]
  1. GET /api/greet/flowable-plain

    Description: Streams plain text lines (one, two, three) from an RxJava Flowable using StreamingOutput. Produces: text/plain Example:

curl -N http://localhost:8080/api/greet/flowable-plain

Response:

one
two
three
  1. GET /api/greet/flowable-sse

    Description: Streams Server-Sent Events (SSE) with data events for one, two, three. Produces: text/event-stream Example:

curl -N http://localhost:8080/api/greet/flowable-sse

Response:

data: one

data: two

data: three

Notes

The -N option in curl is used to disable buffering and see streaming output immediately. The project uses RxJava 2 (Single and Flowable) for reactive programming. Jackson handles JSON serialization with a customized ObjectMapper.

About

Apache CXF Reactive endpoints demo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages