RSS Component
The rss: component is used for polling RSS feeds. Camel will default poll the feed every 60th seconds.
Note: The component currently only supports polling (consuming) feeds.
Using camel-rss in OSGi environment
Camel-rss uses ROME 1.0 and below. This library has class loading issues in OSGi environment. We submitted issue 142 to ROME.
You can also find patched version in this repository. One thing you have to change is version - patched version is marked as 1.0-osgi.
New in Camel 2.0
URI format
rss:rssUri
Where rssUri
is the URI to the RSS feed to poll.
You can append query options to the URI in the following format, ?option=value&option=value&...
Options
Property |
Default |
Description |
---|---|---|
|
|
If |
|
|
Use in combination with the |
|
|
Use in combination with the |
|
|
Specifies whether to add the ROME |
|
|
If |
|
|
Delay in milliseconds between each poll. |
|
|
Milliseconds before polling starts. |
|
|
Set to |
Exchange data types
Camel initializes the In body on the Exchange with a ROME SyndFeed
. Depending on the value of the splitEntries
flag, Camel returns either a SyndFeed
with one SyndEntry
or a java.util.List
of SyndEntrys
.
Option |
Value |
Behavior |
---|---|---|
|
|
A single entry from the current feed is set in the exchange. |
|
|
The entire list of entries from the current feed is set in the exchange. |
Message Headers
Header |
Description |
---|---|
|
Camel 1.x: The entire |
|
Camel 2.0: The entire |
RSS Dataformat
The RSS component ships with an RSS dataformat that can be used to convert between String (as XML) and ROME RSS model objects.
- marshal = from ROME
SyndFeed
to XMLString
- unmarshal = from XML
String
to ROMESyndFeed
A route using this would look something like this:
The purpose of this feature is to make it possible to use Camel's lovely built-in expressions for manipulating RSS messages. As shown below, an XPath expression can be used to filter the RSS message:
Merging multiple incoming feeds
To merge multiple incoming feeds into a single feed, you can apply the custom aggregator, AggregationCollection
, provided with camel-rss. For example:
Here we use a Seda queue to gather up entries from two RSS feeds. The entries are then fed into the custom aggregator which combines these entries into a single ROME SyndFeed
object.
Filtering entries
You can filter out entries quite easily using XPath, as shown in the data format section above. You can also exploit Camel's Bean Integration to implement your own conditions. For instance, a filter equivalent to the XPath example above would be:
The custom bean for this would be: