Skip to content

Instantly share code, notes, and snippets.

@razorcd
Last active November 22, 2020 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save razorcd/6eaf4b9875d42838df1da46f14de90b1 to your computer and use it in GitHub Desktop.
Save razorcd/6eaf4b9875d42838df1da46f14de90b1 to your computer and use it in GitHub Desktop.
Scaling reactive APIs - www.razorcodes.com
@Component
@RequiredArgsConstructor
public class CustomerListener {
private final CustomerRepository<CustomerUpdatedEvent> customerRepository;
@StreamListener("customer-events")
public void customerEventsConsumer(Flux<DataUpdatedEvent> event) {
event.map(this::parseEvent)
.doOnNext(MyService::doBusinessLogic) // returns CustomerUpdatedEvent
.subscribe(customerRepository::save);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment