RSS ComponentAvailable as of Camel 2.0 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: <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.
URI formatrss: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
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"); 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 |