Skip to content

Instantly share code, notes, and snippets.

@smaldini
Last active November 11, 2015 00:52
Show Gist options
  • Save smaldini/8763d0ad2233ba52d35a to your computer and use it in GitHub Desktop.
Save smaldini/8763d0ad2233ba52d35a to your computer and use it in GitHub Desktop.
Spring 5 "Reactive Features" in action powered and demonstrated here with Reactor Streams
@Controller
public class TestController {
@Autowired
//Some reactive database repository
private final ProfileRepository profileRepository;
public TestController(ProfileRepository profileRepository){
this.profileRepository = profileRepository;
}
@RequestMapping("/create-profile")
@ResponseBody
//Decode input in a non blocking fashion
public Stream<Profile> createProfile(@RequestBody Stream<Profile> profiles) {
//transform input Profiles into saved Profile and pass them back in response
return profiles.flatMap(profileRepository::save);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment