|
RSS has been edited by Jonathan Anstey (Dec 09, 2008). Content: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 will set the in body on the returned Exchange with a ROME SyndFeed. Depending on the splitEntries flag Camel will either return a SyndFeed with one SyndEntry or a List of SyndEntrys.
Camel can also set the entire SyndFeed object on the in header (see feedHeader option above to disable): exchange.in.header("org.apache.camel.component.rss.feed", feed)
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=100").marshal().rss().to("mock:marshal"); The idea is to be able 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 utilize a custom AggregationCollection provided with camel-rss. An example usage would look something like this: from("rss:file:src/test/data/rss20.xml?sortEntries=true&consumer.delay=50").to("seda:temp"); from("rss:file:target/rss20.xml?sortEntries=true&consumer.delay=50").to("seda:temp"); from("seda:temp").aggregate(new AggregateRssFeedCollection()).batchTimeout(5000L).to("mock:result"); 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. See Also |
Unsubscribe or edit your notifications preferences
