1
I have two systems, 1 legacy and the new system. The new system will need to be updated in real time, every time the legacy is updated. With that I thought webflux would help me, so I created a POC with Mongo and such,
@RestController
public class ConversionTableProductTypeResource {
@Autowired
private ConversionTableProductTypeService service;
@GetMapping()
public Flux<ConversionTableProductType> getAll() {
return service.findAll();
}
@GetMapping(value = "/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<ConversionTableProductType> getAllStream() {
return service.findAll();
}
@PostMapping()
public Mono<ConversionTableProductType> createTweets(@Valid @RequestBody ConversionTableProductType tweet) {
return service.save(tweet);
}
@DeleteMapping("/{id}")
public Mono<ResponseEntity<Void>> deleteTweet(@PathVariable(value = "id") String tweetId) {
return service.findById(tweetId)
.flatMap(existingTweet ->
service.delete(existingTweet)
.then(Mono.just(new ResponseEntity<Void>(HttpStatus.OK)))
)
.defaultIfEmpty(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}
}
And then I thought this was the solution to my problems, because I thought, the legacy could update Android and my screen would magically update.
It may be that my tests were not correct, because I called the /stream by browser or by Postman.
Could shed some light if I’m thinking the right way, and if so, what I did wrong?