Contact Us 1-800-596-4880

RSS Module Reference

Mule runtime engine version 3.8 reached its End of Life on November 16, 2021. For more information, contact your Customer Success Manager to determine how to migrate to the latest Mule version.

The Mule RSS support makes it possible to integrate easily with RSS feeds.

It contains the following components:

  • rss:feed-splitter

  • rss:entry-last-updated-filter

  • rss:feed-last-updated-filter

  • rss:object-to-feed-transformer

Consuming Feeds

One of the most common patterns is for integrating with RSS is polling for feed updates. With Mule this can be done easily. You must first write your class which receives an RSS Syndication Entry:

EntryReceiver.java

package org.mule.module.rss;

import com.sun.syndication.feed.synd.SyndEntry;

public class EntryReceiver
{
    public void readEntry(@Payload SyndEntry entry) throws Exception
    {
        //do stuff
    }
}

By default the RSS feed is split into entries for you, so for each entry, the component method invokes with the next entry in the feed. Flow configuration:

<mule ...
<rss:feed-last-updated-filter lastUpdate="2017-10-01 13:00:00" acceptWithoutUpdateDate="false" name="feedFilter" />
<rss:object-to-feed-transformer name="ObjectToFeed" />
<http:polling-connector name="PollingHttpConnector" pollingFrequency="1000" discardEmptyContent="false" />

<flow name="flowTest">
  <http:inbound-endpoint address="http://feeds.foxnews.com/foxnews/latest" connector-ref="PollingHttpConnector" />
  <rss:feed-splitter />
  <rss:entry-last-updated-filter lastUpdate="2017-09-22" />
  <echo-component />
</flow>
</mule>

ETags

The Atom HTTP endpoint respects ETags and the 304 Not Modified response code by default, so you don’t need to worry about consuming unnecessary updates.

Accessing the Feed Itself

If you want access to the feed itself, it is available via a header on the current message called feed.object. You could have this injected into your entry point method using annotations:

EntryReceiver.java

public void processEntry(@Payload Entry entry, @Expr("#[header:invocation:feed.object]") Feed feed) throws Exception

If you want to process the Feed in its entirety (not have it split into Entry objects) you can set the following flag on the endpoint:

Now your component invokes once for each feed change no matter how many entries are added or updated. The method for your component should expect a com.sun.syndication.feed.synd.SyndFeed object or just a org.w3c.dom.Document if you want to process the XML model or even an java.io.InputStream or java.lang.String to get a raw representation.

FeedReceiver.java

public void processFeed(@Payload SyndFeed feed) throws Exception
{
    //do stuff
}

Mixing HTTP and RSS endpoints

The rss:endpoint elements are a shortcut for creating a polling http endpoint and splitting a feed. If you are using another non-polling HTTP endpoint in your configuration, configure a HTTP polling endpoint as well, and reference it on your Atom endpoint.

<http:connector name="HttpConnector"/>

<http:polling-connector name="PollingHttpConnector" pollingFrequency="1000" discardEmptyContent="false"/>

<flow name="eventConsumer">
    <http:inbound-endpoint address="http://localhost:9002/events" connector-ref="PollingHttpConnector"/>
    <component class="org.mule.module.rss.EntryReceiver"/>
</flow>

Accessing Feeds over Other Protocols

You can process feeds and process them using other Mule connectors such as JMS, File or XMPP. To do this, the Atom feed needs to be served over the connector, an RSS document is sent over JMS or polled from a file. The RSS schema defines a <rss:feed-splitter/> that can split messages received from an endpoint.

Over JMS

<flow name="feedSplitterConsumer">
    <jms:inbound-endpoint queue="feed.in">
        <rss:feed-splitter/>
    </jms:inbound-endpoint>

    <component class="org.mule.module.atom.event.EntryReceiver"/>
</flow>

Over a File

<flow name="feedSplitterConsumer">
    <file:inbound-endpoint  path="${mule.working.dir}" pollingFrequency="1000" >
        <file:filename-wildcard-filter pattern="*.rss"/>
        <rss:feed-splitter/>
    </file:inbound-endpoint>

    <component class="org.mule.module.atom.event.EntryReceiver"/>
</flow>

Processing Feeds Without the RSS Endpoint

For reference the follow example shows the explicit configuration for reading an Atom feed without using the rss:endpoint.

<http:polling-connector name="PollingHttpConnector" pollingFrequency="1000" discardEmptyContent="false"/>

<flow name="feedConsumer">
    <http:inbound-endpoint address="http://rossmason.blogspot.com/feeds/posts/default" connector-ref="PollingHttpConnector">
        <rss:feed-splitter/>
        <rss:entry-last-updated-filter/>
    </http:inbound-endpoint>

    <component class="org.mule.module.rss.EntryReceiver"/>
</flow>

The rss:entry-last-updated-filter comes after the <rss:feed-splitter/> because you need to split the feeds so that the filter can process them. Also we do not set a lastUpdate date on the filter, which implies the default behavior that all available entries are read, and then only new entries since the last read are processed.

RSS Module Reference

RSS is a popular syndication format used by many websites to provide a feed of data such as news or updates.

Transformers

These are transformers specific to this transport. Note that these are added automatically to the Mule registry at start up. When doing automatic transformations these are included when searching for the correct transformers.

Table 1. Transformers
Name Description

object-to-feed-transformer

Transforms the payload of the message to a com.sun.syndication.feed.synd.SyndFeed instance.

Filters

Filters can be used to control which data is allowed to continue in the flow.

Table 2. Filters
Name Description

entry-last-updated-filter

Filters RSS entry objects based on their last update date. This is useful for filtering older entries from the feed. This filter works only on RSS SyndEntry objects not SyndFeed objects.

feed-last-updated-filter

Filters the whole RSS Feed based on its last update date. This is useful for processing a feed that has not been updated since a specific date. This filter works only on RSS SyndFeed objects.

Feed Splitter

Splits the entries of a feed into single entry objects. Each entry will be a separate message in Mule.

No child elements of feed-splitter.