16

RSS Feeds With Rome and Jersey From a Microservice

 3 years ago
source link: https://nixmash.com/java/rss-feeds-with-rome-from-a-microservice/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

RSS Feeds With Rome and Jersey From a Microservice

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.

rss0308a.png

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.

rss0308b.png

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.

rss0308c.png

Retrieving the RSS+XML from the Web Module

Our Web Controller method looks like this.

rss0308d.png

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.

rss0308e.png

CategoriesJavaTagsJava, Jersey, Microservices, MVC, Spring


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK