Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • use of declarative programming
  • how to perform Http binding in ServiceMix
  • how to use an ActiveMQ message broker
  • how to use the Jencks JCA container
  • how to use the Geronimo Transaction Manager via the Jencks factory bean

The source code for the JMS Http Binding example is located in the ServiceMix installation directory under the examples\jmshttp-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 connect the JMS Http bindings to a simple service component. One component listens for a JMS message on topic 'demo.org.servicemix.source' while another publishes processed messages to topic 'demo.org.servicemix.result'. A simple JMS client is provided so that messages can be sent and received to and from the ServiceMix Container.

Running the

...

Http Binding Example

  1. From a command shell, go to the JMS Binding example directory:
    Code Block
    cd [servicemix_install_dir]\examples\jmshttp-binding
    
    where servicemix_install_dir is the directory in which ServiceMix was installed.
  2. Then type:
    Code Block
    [servicemix_install_dir]\bin\servicemix servicemix.xml
    
  3. To start sending and receiving of messages from the JMS topicsHttp server, send JMS an initial message. To do this, compile and run a simple JMS Http client. The client is built and run from source code using Ant. Execute Ant from the JMS Binding directory: servicemix_install_dir\examples\jmshttp-binding. To run the JMS Http client type:
    Code Block
    ant
    

    Ant will compile and run the simple JMS Http client, JMSClient HttpClient, which performs a JMS based request-response simple post on the Http Server into the ServiceMix container before returning the results to the console.

Stopping the

...

Http Binding Example

To terminate the JMS 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.

...

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

Panel
borderColor#ccc
titleJMS Http Binding Example Message Flow Diagram
borderStylesolid

Image RemovedImage Added


Messages flow through the components as follows:

  1. HttpClient, a java standalone program connects to http://localhost:8912Image Added through URLConnection class. It then sends the file "request.xml" to this port.
  2. httpReceiver, an http server, being a listenser on http://localhost:8912Image Added receives the message.
  3. It then sends the message to stockQuote as specified in its destinationService property, via NMR.
  4. stockQuote sends in into another service, soapEndpoint for processing.
  5. soapEndpoint sends the response to stockQuote.
  6. stockQuote send the response to httpReceiver via NMR.
  7. httpReceiver sends the response to http://localhost:8912Image Added.
  8. HttpClient reads the response
  9. JMSClient, through ActiveMQConnectionFactory, connects to the topic named "demo.org.servicemix.source" and sends a text message.
  10. jencks (the JCA resource adapter) listens on port 61616 for messages.
  11. inputReceiver subscribes to the "demo.org.servicemix.source" topic via jencks and receives the JMS message.
  12. inputReceiver normalizes the JMS message and sends it to outputSender via the Normalized Message Router (NMR).
  13. outputSender marshals the normalized message to a JMS message and uses jmsTemplate to publish the message on the "demo.org.servicemix.result" topic.
  14. jmsTemplate publishes it on the "demo.org.servicemix.result" topic using jmsFactory to get a connection to the result topic.
  15. JMSClient, also a subscriber of topic "demo.org.servicemix.result," receives the message.
  16. The response is printed on the console.

...