Opens a new event stream according to your request filters. Unlike our other APIs, a request to /api/events/ returns a stream of data, where each line is a JSON object. The response body contains all the events in that stream. Since streams by definition go on forever, Real-time Data Streaming will never end the response without some external reason.
xxxxxxxxxx
@RestController
@RequestMapping("product")
public class ProductStreamController {
@Autowired
private Flux<ProductDto> flux;
@GetMapping(value = "stream/{maxPrice}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<ProductDto> getProductUpdates(@PathVariable int maxPrice){
return this.flux
.filter(dto -> dto.getPrice() <= maxPrice);
}
}