Skip to content

Commit

Permalink
Exercice 11 : Use mutiny's Uni only, rm Multi mention
Browse files Browse the repository at this point in the history
  • Loading branch information
RasDeaks committed Oct 24, 2023
1 parent 3a29481 commit 56efaed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
3 changes: 1 addition & 2 deletions code/exercise_011_Going_Reactive/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ Note: one of the reasons we removed the `quarkus-hibernate-orm-rest-data-panache
* Remove the setting `quarkus.datasource.jdbc.url`, and replace it with this setting:
` quarkus.datasource.reactive.url=postgresql://localhost:8765/postgres`
* Go to your `Product` class. Delete the old `PanacheEntity` import, and find the proper import to use now.
* Now, go to `ProductsResource`, and make it work again. Note that you can return `Uni` or `Multi` reponses from your resource methods now that you have RESTeasy reactive.
Try two options: returning a `Multi<Product>` from the `products()` method, or returning a `Uni<List<Product>>`. What’s the conceptual difference between these?
* Now, go to `ProductsResource`, and make it work again. Note that you can return `Uni` responses from your resource methods now that you have RESTeasy reactive.
* For the `PUT` endpoint, do the following:
- Start with `Product.<Product>findById(id)`, and `flatMap` the resulting `Uni`.
- Within the `flatMap`, update the product, and invoke `persistAndFlush`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package com.lunatech.training.quarkus;

import io.quarkus.hibernate.reactive.panache.common.WithSession;
import io.quarkus.hibernate.reactive.panache.common.WithSessionOnDemand;
import io.quarkus.hibernate.reactive.panache.common.WithTransaction;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;

import jakarta.validation.Valid;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
Expand All @@ -18,13 +14,7 @@
public class ProductsResource {

@GET
public Multi<Product> products() {
return getAllProducts().toMulti()
.flatMap(list -> Multi.createFrom().iterable(list));
}

@WithTransaction
public Uni<List<Product>> getAllProducts(){
public Uni<List<Product>> products() {
return Product.listAll();
}

Expand Down

0 comments on commit 56efaed

Please sign in to comment.