Manage RSS feeds with the Rome API

Get automated build reports from your continuous integration server

RSS is a widely used means of publishing syndicated content, from bloglines to build reports. The large number of individual formats (at least six flavors of RSS plus Atom) can make it difficult to manipulate the feeds by hand, however. In this article John Ferguson Smart shows you how to use the Rome API to read and process RSS feeds in any format. You'll also learn how to set up an RSS feed to deliver build reports in a continuous integration environment, using Continuum as your CI server.

RSS (Really Simple Syndication) is an established way of publishing short snippets of information, such as news headlines, project releases, or blog entries. Modern browsers such as Firefox, and more recently Internet Explorer 7, and mail clients such as Thunderbird recognize and support RSS feeds; not to mention the a large number of dedicated RSS readers (also known as aggregators) out there.

RSS feeds aren't just for end-users, though. A variety of application scenarios could require you to read, publish, or process RSS feeds from within your code. Your application could need to publish information through a set of RSS feeds, or need to read, and possibly manipulate, RSS data from another source. For example, some applications use RSS feeds to inform users of changes to the application database that could affect them.

RSS feeds also can be useful inside of a development project. Tools like Trac let you use RSS feeds to monitor changes made to a Subversion repository or to a project Web site, which can be a good way to easily keep tabs on the status of many projects simultaneously. Some development projects, for instance, use RSS feeds to monitor continuous integration build results. End users simply subscribe to the CI server's feed in their RSS reader or RSS-enabled Web browser. The server publishes real-time build results in RSS format, which the client can then consult at any time without having to go to the server's Web site.

In this article, I'll show you how to manipulate RSS feeds in Java using the Rome (RSS and Atom utilities) API. I'll also walk you through a concrete application of these techniques, where you'll write a simple class that publishes build results from a Continuum build server in RSS format.

Introducing the Rome API

You could define RSS very simply by saying that it is an XML format that allows you to share information in a condensed manner; for example by publishing only a title, a description, and a link to a more detailed article.

Now, strictly speaking RSS is not a single format, but a family of formats. Among the many flavors of RSS are RSS 0.91 (in Netscape and Userland "sub-flavors"), RSS 0.92, RSS 0.93, RSS 0.94, RSS 1.0, and RSS 2.0. More recently Atom 1.0 has also entered the mix, introducing many subtle and non-so-subtle compatibility issues.

Although you can very well write your own RSS script directly (after all, it's just XML!), doing so forces you to choose, and stick to, one particular format. The issue is even trickier if you have to read and process external RSS feeds, which can come in a variety of formats. This is where an API like Rome comes in handy. In addition to being fluent in the many flavors of RSS, as you will see, the Rome API is easy to use and intuitive to understand, which helps to make coding more productive and code more maintainable.

Rome is an open source Java API for reading and publishing RSS feeds in a relatively format-neutral way. Originally developed by Sun and now a project, Rome is designed to provide a level of abstraction to mask the subtle differences between the various formats. This lets you concentrate on publishing and/or processing content, rather than wrestling with the particularities of each format. Rome was designed from the onset to be easy to use, flexible, and to support all existing RSS flavors.

Get started with Rome

In this article you'll try your hand at two exercises using the Rome API. First, you'll create a simple feed, populate it, and publish it, with a few small steps in between. Once you have the basics down you can tackle the more advanced exercise of setting up syndicated build reports from a continuous integration server like Continuum.

You'll need to download Rome 0.9, which you can get from the Rome homepage. Rome needs Java 1.4 or higher, and requires JDOM 1.0 for XML processing, which you will also need to download if you don't have it already. If you're using Maven, all you need to do is to add the following dependency to your pom.xml:


1 2 3 4 Page
Join the discussion
Be the first to comment on this article. Our Commenting Policies
See more