RSSPage edited by Ćukasz DywickiInformation about OSGi and ROME issues.RSS ComponentThe 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.
New in Camel 2.0 URI formatrss:rssUri Where rssUri is the URI to the RSS feed to poll.
Exchange data typesCamel 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.
Message Headers
RSS DataformatThe RSS component ships with an RSS dataformat that can be used to convert between String (as XML) and ROME RSS model objects.
A route using this would look something like this: from("rss:file:src/test/data/rss20.xml?splitEntries=false&consumer.delay=1000").marshal().rss().to("mock:marshal"); 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: // only entries with Camel in the title will get through the filter from("rss:file:src/test/data/rss20.xml?splitEntries=true&consumer.delay=100") .marshal().rss().filter().xpath("//item/title[contains(.,'Camel')]").to("mock:result"); Merging multiple incoming feedsTo merge multiple incoming feeds into a single feed, you can apply the custom aggregator, AggregationCollection, provided with camel-rss. For example: Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20
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 entriesYou 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: // only entries with Camel in the title will get through the filter from("rss:file:src/test/data/rss20.xml?splitEntries=true&consumer.delay=100"). filter().method("myFilterBean", "titleContainsCamel").to("mock:result"); The custom bean for this would be: public static class FilterBean { public boolean titleContainsCamel(@Body SyndFeed feed) { SyndEntry firstEntry = (SyndEntry) feed.getEntries().get(0); return firstEntry.getTitle().contains("Camel"); } } See Also
Change Notification Preferences
View Online
|
View Change
|
Add Comment
|
- [CONF] Apache Camel > RSS confluence
- [CONF] Apache Camel > RSS confluence
- [CONF] Apache Camel > RSS confluence