Skip to content

Commit 893f624

Browse files
committed
feat: solution for step 5
1 parent d398b60 commit 893f624

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

bookmark-service/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
<artifactId>quarkus-smallrye-metrics</artifactId>
5252
</dependency>
5353
<!-- Step 5 dependencies -->
54-
<!-- <dependency>-->
55-
<!-- <groupId>io.quarkus</groupId>-->
56-
<!-- <artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId>-->
57-
<!-- </dependency>-->
54+
<dependency>
55+
<groupId>io.quarkus</groupId>
56+
<artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId>
57+
</dependency>
5858
<!--/ Step 5 dependencies -->
5959
<!-- Step 6 dependencies -->
6060
<!-- <dependency>-->

bookmark-service/src/main/java/fr/loicmathieu/bookmarkit/BookmarkResource.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package fr.loicmathieu.bookmarkit;
22

3+
import io.smallrye.reactive.messaging.annotations.Emitter;
4+
import io.smallrye.reactive.messaging.annotations.Stream;
35
import org.eclipse.microprofile.config.inject.ConfigProperty;
46
import org.eclipse.microprofile.metrics.annotation.Counted;
57
import org.eclipse.microprofile.metrics.annotation.Timed;
68
import org.eclipse.microprofile.openapi.annotations.Operation;
9+
import org.eclipse.microprofile.reactive.messaging.Outgoing;
710

811
import javax.annotation.PostConstruct;
12+
import javax.inject.Inject;
913
import javax.transaction.Transactional;
1014
import javax.ws.rs.Consumes;
1115
import javax.ws.rs.DELETE;
@@ -26,6 +30,8 @@
2630
public class BookmarkResource {
2731
@ConfigProperty(name="greeting") String greeting;
2832

33+
@Inject @Stream("bookmarks") Emitter<Bookmark> emitter;
34+
2935
@PostConstruct
3036
void init(){
3137
System.out.println("Hello " + greeting);
@@ -55,6 +61,7 @@ public Bookmark get(@PathParam("id") Long id) {
5561
@Timed(name="create.time")
5662
public Response create(Bookmark bookmark){
5763
bookmark.persist();
64+
emitter.send(bookmark);
5865
return Response.created(URI.create("/bookmarks/" + bookmark.id)).build();
5966
}
6067

bookmark-service/src/main/resources/application.properties

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,12 @@ quarkus.datasource.password = connor
88
quarkus.hibernate-orm.database.generation=drop-and-create
99

1010
greeting=World
11-
%dev.greeting=Dev
11+
%dev.greeting=Dev
12+
13+
# Configures the AMQP broker credentials.
14+
amqp-username=quarkus
15+
amqp-password=quarkus
16+
# Configure the AMQP connector to write to the `bookmark` address
17+
mp.messaging.outgoing.bookmarks.connector=smallrye-amqp
18+
mp.messaging.outgoing.bookmarks.address=bookmarks
19+
mp.messaging.outgoing.bookmarks.durable=true

0 commit comments

Comments
 (0)