RSSPage edited by Glen Mazza
Comment:
updated ROME library info
Changes (2)
Full ContentRSS ComponentThe 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>
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
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache Camel > RSS confluence
- [CONF] Apache Camel > RSS confluence
- [CONF] Apache Camel > RSS confluence
- [CONF] Apache Camel > RSS confluence