Publishing saved comments to a chat service
In the previous chapter, we connected our images
service to the comments
service via Spring Cloud Stream. This let us transmit new comments over the wire to a service dedicated to storing them in a MongoDB data store.
The following screenshot shows us entering a new comment:
To carry on this use case to its natural conclusion, it's expected that after storing a message, we'd want to share it with everyone, right? To do so, let's pick up with the comment
microservice's CommentService
.
In the previous chapter, the comments
service transformed an incoming stream of Flux<Comment>
into a Flux<Void>
, a stream of voids. This had the effect of, essentially, dropping the stream at this point. In this chapter, we want to take that incoming stream of comments and forward them.
This is accomplished by altering the Comment.save()
operation as follows:
@StreamListener
@Output(Processor.OUTPUT)
public Flux<Comment> save(@Input(Processor...