We support working with RSS and Atom via the Romelibrary. We support both the polling of existing RSS feeds to generate JBI messages and the generation of RSS feeds from JBI messages.

Polling RSS/Atom feeds

To see this component in action see the Example in the binary distribution.

You can configure the RSS component as follows in your servicemix.xml

<!-- lets poll for updates to news sites -->
<sm:activationSpec componentName="rss" service="my:rss" destinationService="my:trace">
	<sm:component>
		<bean class="org.apache.servicemix.components.rss.RssPollingComponent">
  <property name="outputType" value="rss_2.0"/>
  <property name="period" value="5000"/>
  <property name="lastPolledDate">
    <value>2005/08/10</value>
  </property>


  <property name="urlStrings">
    <list>
      <value>http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml</value>
      <value>http://rss.cnn.com/rss/cnn_topstories.rss</value>
    </list>
  </property>
		</bean>
	</sm:component>
</sm:activationSpec>

 

Generating RSS/Atom feeds

This component is used to consume inbound JBI messages and write them to an RSS/Atom feed. You can then use expressions to extract the title and entry content for the items.

The following example shows using XPath expression

<sm:activationSpec componentName="feedWriter" 
					 service="foo:feedWriter">
	<sm:component><bean class="org.apache.servicemix.components.rss.FeedWriter">

   <property name="feedFile" value="file:target/serviceMixFeed.xml" />
	
   <!--  define expressions for the entry title and value -->
   <property name="entryTitle">
     <bean class="org.apache.servicemix.expression.JaxenStringXPathExpression">
       <constructor-arg value="concat('Message ', /sample/@id, ' - ', /sample/@sent)" />
     </bean>
   </property>
   <property name="entryValue">
     <bean class="org.apache.servicemix.expression.JaxenStringXPathExpression">
       <constructor-arg value="concat('This is an entry with ID ', /sample/@id, ' sent: ', /sample/@sent, '. There is not much else in the message to tell :)')" />
     </bean>
   </property>
  </bean></sm:component>
</sm:activationSpec>