I blogged about setting up RSS Feeds in Spring a while back. If I had to describe the process outlined in that post with a single word, it would be Abstractions. Spring uses Rome Tools as well, but with layers of abstraction on top. In this post we're going to use the Rome RSS Library straight-up with Jersey, and serve the feed from a Microservice. The end result is exactly the same as in its Spring Boot form, and getting there is a whole lot cleaner.
NixMash Microblog has the following layout (so far). A small shared Jangles module, a Posts Microservice, a Solr Microservice, and a Web Module. To produce the feed we'll hit a Controller in the Web Module which will retrieve the feed from a Posts Resource in PostService.
In the Posts Microservice
Our PostService module has the Rome RSS Library. The Web module simply retrieves the feeds as an application/rss+xml Media Type. Here's our Microservice Endpoint. We won't go into creating the feed in Rome since that is covered many places and is straightforward.
Retrieving the RSS+XML from the Web Module
Our Web Controller method looks like this.
We're going to identify our Controller Method output as application/rss+xml and call our Web PostService class to retrieve the Microservice contents as a String. The overloaded getRestHtml() method performs a number of functions in returning content from our Posts Microservice, so only the essential elements in retrieving our RSS Feed are shown.