Overview of the ServiceMix 2.x RSS Binding Example

The following procedure describes how to run the RSS Binding example in ServiceMix and provides details regarding what the RSS Binding does. For information on the business use case, please refer to: Use Case for RSS Binding.

The RSS Binding example illustrates:

  • use of declarative programming
  • how to perform an RSS binding in ServiceMix

The source code for the RSS Binding example is located in the ServiceMix installation directory under the examples\rss-binding directory in the servicemix.xml file. It is recommended that you refer to the source code while reading this document.

This example shows how to monitor RSS feeds for changes. The main component of this example periodically polls a list of RSS news feeds and when an update is found the new RSS items are displayed on the console.

Running the RSS Binding Example


On a slow news day, you may have wait a while to see any output! (smile)


  1. From a command shell, go to the RSS Binding example directory:
    cd [servicemix_install_dir]\examples\rss-binding
    
    where servicemix_install_dir is the directory in which ServiceMix was installed originally.
  2. Then type:
    [servicemix_install_dir]\bin\servicemix servicemix.xml
    

    Handy Hint

    Add $SERVICEMIX_HOME/bin directory to $PATH variable to simplify execution of the examples.


Stopping the RSS Binding Example

To terminate the RSS Binding example, type "CTRL-C" in the command shell in which it is running and answer "y" to the "Terminate batch job (y/n)?" question.

How it Works

The diagram below illustrates the flow of messages through the RSS Binding components:

RSS Binding Example Message Flow Diagram


Messages flow through the components as follows:

  1. The rss component, which is implemented by RssPollingComponent class, uses customEditorConfigurer bean to parse the Date variable lastPolledDate into the specified format (yyyy/MMM/dd). lastPolledDate will be used to determine the new items added on the RSS feed.
  2. The rss component periodically polls RSS feeds defined on its urlStrings property for changes. In this case rss component monitors the following RSS feeds: http://rss.cnn.com/rss/cnn_topstories.rss and http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml.
  3. When an update is found, the rss component creates a normalized message that contains the new items. It then sends the normalized message to the NMR. The NMR routes the message to the trace component.
  4. The trace component displays the RSS news items on the console.

Output from running [servicemix_install_dir]\bin\servicemix servicemix.xml looks like the following:

  
<item>
<title>Bush supporters' cars allegedly defaced by war veteran</title>
<link>http://www.cnn.com/rssclick/2005/US/12/16/bush.vandalism.ap/index.html?sec
tion=cnn_topstories</link>
<description>Read full story for latest details.</description>
<pubDate>Sat, 17 Dec 2005 00:52:01 GMT</pubDate>
<guid isPermaLink="false">http://www.cnn.com/rssclick/2005/US/12/16/bush.vandali
sm.ap/index.html?section=cnn_topstories</guid>
</item>
<item>
<title>Stern says goodbye to terrestrial radio</title>
<link>http://www.cnn.com/rssclick/2005/SHOWBIZ/12/16/stern.last.day.ap/index.htm
l?section=cnn_topstories</link>
<description>Read full story for latest details.</description>
<pubDate>Sat, 17 Dec 2005 02:13:07 GMT</pubDate>
<guid isPermaLink="false">http://www.cnn.com/rssclick/2005/SHOWBIZ/12/16/stern.l
ast.day.ap/index.html?section=cnn_topstories</guid>
</item>

Details

The following table provides more details about the function of each component and bean in the servicemix.xml file:

Component or Bean ID

Description

rss

This component polls RSS feeds for changes and is implemented by RssPollingComponent class. The property urlStrings defines the RSS feeds to be monitored. When one of the RSS feeds being monitored is updated, this component will convert the content of the RSS feed into a normalized message and send it to a trace component via Normalized Message Router (NMR).

trace

This component accepts a normalized message and display its content to the console.

customEditorConfigurer

This bean allows convenient registration of custom property editors that can modify application context's bean definitions. It uses CustomDateEditor, a propertyEditor for java.util.Date to reformat date variable lastPolledDate.

Related Documentation

For more information on the following topics please see:

We support working with RSS and Atom via the Rome library. We support both the polling of existing RSS feeds to generate JBI messages (the example documented above) and the generation of RSS feeds from JBI messages. To see an example of how to generate RSS feeds from JBI messages go here.

For a brief explanation of the XML tags in the servicemi.xml file, please see:


  • No labels

3 Comments

  1. Unknown User (lmalgeri)

    Jason,

    1. Diagram: can you change the orange oval to just say "News Feed Sites" and make it have another oval behind it showing slightly. And make the orange oval smaller. See the Basic Use Case "OrderTransformer" component to get the idea of how to have the first oval overlay the second one.

    2. Add the customEditorConfigurer bean outside of the JBI as a small green bean--see the Basic example, jmsTemplate bean for an idea of how to make this one look.

    3. The rss component "uses" the customEditorConfigurer so add a red arrow to the customEditorConfigurer bean with the word "uses" on it. I assume this step occurs before or right after the "polls" step.

    You need to figure that out.

    4. Can you add the customEditorConfigurer to the table and explain how it is used/what it does?

    Other than that, it looks good.

  2. Looks good to me!

    cheers,

    Rob

  3. Unknown User (lmalgeri)

    Jason, I deleted the last news item in the output because it had foul language in it. Just an fyi--I was re-reviewing and caught that.