Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

RSS Module Reference

The Mule RSS support makes it possible to integrate easily with RSS feeds via the Rome project.

Consuming Feeds

The use of RSS endpoints is deprecated. RSS endpoints were removed in Mule 3.2.0. Use the approach described in the Mixing HTTP and RSS Endpoints section.

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


         
      
1
2
3
4
5
6
7
8
9
10
11
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 is invoked with the next entry in the feed. The flow configuration would look like:


         
      
1
2
3
4
<flow name="eventConsumer">
    <rss:inbound-endpoint address="http://localhost:9002/events"/>
    <component class="org.mule.module.rss.EntryReceiver"/>
</flow>

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


          
       
1
public void processEntry(@Payload Entry entry, @Expr("#[header:invocation:feed.object]") Feed feed) throws Exception
The @Expr annotation is only available in the Mule Community Edition.

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


          
       
1
<rss:inbound-endpoint address="http://localhost:9002/events" splitFeed="false/>

Now your component is invoked once for each feed change no matter how many entries were added or updated. The method on you 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


          
       
1
2
3
4
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 you will need to configure a HTTP polling endpoint as well and reference it on your atom endpoint.


         
      
1
2
3
4
5
6
7
8
<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, such as when 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


          
       
1
2
3
4
5
6
7
<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


          
       
1
2
3
4
5
6
7
8
<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 an RSS Endpoint

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


          
       
1
2
3
4
5
6
7
8
9
10
<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>

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

Feed splitter

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

No Child Elements of <feed-splitter…​>

Entry last updated filter

Will filter 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.

Attributes of <entry-last-updated-filter…​>

Name Type Required Default Description

lastUpdate

string

no

The date from which to filter events from. Any entries that were last updated before this date will not be accepted. The date format is: yyyy-MM-dd hh:mm:ss, for example 2008-12-25 13:00:00. If only the date is important you can omit the time part. You can set the value to 'now' to set the date and time that the server is started. Do not set this attribute if you want to receive all available entries then any new entries going forward. This is the default behavior and suitable for many scenarios.

acceptWithoutUpdateDate

boolean

no

true

Whether an entry should be accepted if it doesn’t have a Last Update date set.

No Child Elements of <entry-last-updated-filter…​>

Object to feed transformer

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

No Child Elements of <object-to-feed-transformer…​>