You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

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 HTTP 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 feed for changes. The main component polls the RSS periodically and when an update is found the RSS item is send to a trace component for logging.

Running the RSS Binding Example

  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 HTTP 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 HTTP Binding components:

HTTP Binding Example Message Flow Diagram


Messages flow through the components as follows:

  1. rss component implemented by RssPollingComponent class polls RSS feeds defined on its urlStrings property. In this case rss component monitors http://rss.cnn.com/rss/cnn_topstories.rss and http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml

Typical output looks like the following:

Output from running [servicemix_install_dir]\bin\servicemix servicemix.xml:

  
Loading ServiceMix from file: C:\exist\servicemix\servicemix-2.0.2\examples\http
-binding\servicemix.xml
17:34:34.768 EVENT  Starting Jetty/4.2.20RC0
17:34:34.848 EVENT  Started ServletHttpContext[/]
17:34:34.858 EVENT  Started SocketListener on 127.0.0.1:8912
17:34:34.858 EVENT  Started org.mortbay.jetty.Server@1f06dc3

Output from running Ant:

Buildfile: build.xml

init:

compile:

run:
     [echo] Running example client
     [java] <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="htt
p://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSch
ema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http:/
/schemas.xmlsoap.org/soap/encoding/" soap:encodingStyle="http://schemas.xmlsoap.
org/soap/encoding/"><soap:Body><n:getQuoteResponse xmlns:n="urn:xmethods-delayed
-quotes"><Result xsi:type="xsd:float">88.8</Result></n:getQuoteResponse></soap:B
ody></soap:Envelope>asdf

BUILD SUCCESSFUL
Total time: 6 seconds

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).

StreamWriterComponent

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

Related Documentation

For more information on the following topics please see:

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


  • No labels