Skip to content

Commit

Permalink
feat: solution for step 5
Browse files Browse the repository at this point in the history
  • Loading branch information
loicmathieu committed Oct 2, 2019
1 parent d398b60 commit 893f624
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
8 changes: 4 additions & 4 deletions bookmark-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
<artifactId>quarkus-smallrye-metrics</artifactId>
</dependency>
<!-- Step 5 dependencies -->
<!-- <dependency>-->
<!-- <groupId>io.quarkus</groupId>-->
<!-- <artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId>
</dependency>
<!--/ Step 5 dependencies -->
<!-- Step 6 dependencies -->
<!-- <dependency>-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package fr.loicmathieu.bookmarkit;

import io.smallrye.reactive.messaging.annotations.Emitter;
import io.smallrye.reactive.messaging.annotations.Stream;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.metrics.annotation.Counted;
import org.eclipse.microprofile.metrics.annotation.Timed;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.reactive.messaging.Outgoing;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
Expand All @@ -26,6 +30,8 @@
public class BookmarkResource {
@ConfigProperty(name="greeting") String greeting;

@Inject @Stream("bookmarks") Emitter<Bookmark> emitter;

@PostConstruct
void init(){
System.out.println("Hello " + greeting);
Expand Down Expand Up @@ -55,6 +61,7 @@ public Bookmark get(@PathParam("id") Long id) {
@Timed(name="create.time")
public Response create(Bookmark bookmark){
bookmark.persist();
emitter.send(bookmark);
return Response.created(URI.create("/bookmarks/" + bookmark.id)).build();
}

Expand Down
10 changes: 9 additions & 1 deletion bookmark-service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@ quarkus.datasource.password = connor
quarkus.hibernate-orm.database.generation=drop-and-create

greeting=World
%dev.greeting=Dev
%dev.greeting=Dev

# Configures the AMQP broker credentials.
amqp-username=quarkus
amqp-password=quarkus
# Configure the AMQP connector to write to the `bookmark` address
mp.messaging.outgoing.bookmarks.connector=smallrye-amqp
mp.messaging.outgoing.bookmarks.address=bookmarks
mp.messaging.outgoing.bookmarks.durable=true

0 comments on commit 893f624

Please sign in to comment.