This page is outdated, for the current version see: https://github.com/apache/camel/blob/master/components/camel-rss/src/main/docs/rss-component.adoc
RSS Component
The rss: component is used for polling RSS feeds. Camel will default poll the feed every 60th seconds.
Maven users will need to add the following dependency to their pom.xml
for this component:
xml<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-rss</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency>
Note: The component currently only supports polling (consuming) feeds.
New in Camel 2.0Camel-rss internally uses a patched version of ROME hosted on ServiceMix to solve some OSGi class loading issues.
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
confluenceTableSmall
Property | Default | Description |
---|---|---|
|
| If |
|
| Is only used by the split entries to filter the entries to return. Camel will default use the UpdateDateFilter that only return Use in combination with the |
|
| Camel 2.5: Sets whether all entries identified in a single feed poll should be delivered immediately. If true, only one entry is processed per consumer.delay. Only applicable when splitEntries is set to true. |
|
| Is only used by the filter, as the starting timestamp for selection never entries Use in combination with the |
|
| Sets Specifies whether to add the ROME |
|
| If |
|
| Delay in millis milliseconds between each poll. |
|
| Millis Milliseconds before polling starts. |
|
| Set to |
username | Camel 2.16: For basic authentication when polling from a HTTP feed | |
password | Camel 2.16: For basic authentication when polling from a HTTP feed |
Exchange data types
Camel will set initializes the in In body on the returned Exchange with a ROME SyndFeed
. Depending on the value of the splitEntries
flag, Camel will returns either return a SyndFeed
with one SyndEntry
or a java.util.List
of SyndEntrys
.
confluenceTableSmall
Option | Value | Behavior |
---|---|---|
|
| Only a A single entry from the currently being processed current feed is set in the new exchange feed. |
|
| The entires entire list of entries from the current feed is set in the new exchange feed. |
Camel can also set the entire SyndFeed object on the in header (see feedHeader option above to disable):
Message Headers
confluenceTableSmall
Header | Description |
---|---|
| 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:
...
{snippet:id=ex|lang=java|url=
...
camel/trunk/components/camel-rss/src/test/java/org/apache/camel/dataformat/rss/RssDataFormatTest.java}
...
The idea purpose of this feature is to be able 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:
...
{snippet:id=ex|lang=java|url=
...
camel/trunk/components/camel-rss/src/test/java/org/apache/camel/dataformat/rss/RssFilterWithXPathTest.java}
Merging multiple incoming feeds
To merge multiple incoming feeds into a single feed, you can utilize a custom AggregationCollection provided with camel-rss. An example usage would look something like this:
Query parameters
If the URL for the RSS feed uses query parameters, this component will understand them as well, for example if the feed uses alt=rss
, then you can for example do
from("rss:http://someserver.com/feeds/posts/default?alt=rss&splitEntries=false&consumer.delay=1000").to("bean:rss");
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:{snippet:id=ex1
...
|lang=java|url=
...
camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/
...
RssFilterTest.java}
...
Here we use a Seda queue to gather up entries from two RSS feeds. The entries are then fed into a custom aggregator which combines these entries into a single ROME SyndFeed object.
...
custom bean for this would be:{snippet:id=ex2|lang=java|url=camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssFilterTest.java}Endpoint See Also
...