| <?xml version="1.0" encoding="ISO-8859-1" ?> |
| <!-- |
| ~ Licensed to the Apache Software Foundation (ASF) under one |
| ~ or more contributor license agreements. See the NOTICE file |
| ~ distributed with this work for additional information |
| ~ regarding copyright ownership. The ASF licenses this file |
| ~ to you under the Apache License, Version 2.0 (the |
| ~ "License"); you may not use this file except in compliance |
| ~ with the License. You may obtain a copy of the License at |
| ~ |
| ~ http://www.apache.org/licenses/LICENSE-2.0 |
| ~ |
| ~ Unless required by applicable law or agreed to in writing, |
| ~ software distributed under the License is distributed on an |
| ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| ~ KIND, either express or implied. See the License for the |
| ~ specific language governing permissions and limitations |
| ~ under the License. |
| --> |
| |
| <document> |
| <properties> |
| <title>Apache Synapse - Sample 251</title> |
| </properties> |
| <body> |
| <section name="Sample 251: Switching from HTTP/S to JMS"> |
| <div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse"> |
| |
| <proxy name="StockQuoteProxy" transports="http"> |
| <target> |
| <endpoint> |
| <address |
| uri="jms:/SimpleStockQuoteService?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue"/> |
| </endpoint> |
| <inSequence> |
| <property action="set" name="OUT_ONLY" value="true"/> |
| </inSequence> |
| <outSequence> |
| <send/> |
| </outSequence> |
| </target> |
| <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/> |
| </proxy> |
| |
| </definitions></div> |
| <subsection name="Objective"> |
| <p> |
| This sample demonstrates receiving messages over HTTP/S and forwarding them to |
| a JMS queue |
| </p> |
| </subsection> |
| <subsection name="Pre-requisites"> |
| <p> |
| <ul> |
| <li> |
| Setup and start a JMS broker (Apache ActiveMQ can be used as the |
| JMS broker for this scenario. Refer <a href="setup/jms.html#pre">JMS setup guide</a> |
| for information on how to run ActiveMQ.) |
| </li> |
| <li> |
| Enable the JMS transport receiver of the sample Axis2 server (Refer |
| <a href="setup/jms.html#server">JMS setup guide</a> for details) |
| </li> |
| <li> |
| Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2 (Since |
| the JMS receiver is enabled, Axis2 will start polling on a JMS queue) |
| </li> |
| <li> |
| Start Synapse using the configuration numbered 251 (repository/conf/sample/synapse_sample_251.xml) |
| <div class="command"> |
| Unix/Linux: sh synapse.sh -sample 251<br/> |
| Windows: synapse.bat -sample 251 |
| </div> |
| </li> |
| </ul> |
| </p> |
| </subsection> |
| <subsection name="Executing the Client"> |
| <p> |
| This Synapse configuration creates a proxy service over HTTP and forwards |
| received messages to a JMS queue. To test this functionality, send a place order |
| request to Synapse over HTTP as follows. |
| </p> |
| <div class="command">ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy -Dmode=placeorder -Dsymbol=MSFT</div> |
| <p> |
| Note that the target endpoint of the proxy service points to a JMS queue in the |
| ActiveMQ broker. |
| </p> |
| <div class="consoleOutput">jms:/SimpleStockQuoteService?transport.jms.ConnectionFactoryJNDIName= |
| QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory& |
| java.naming.provider.url=tcp://localhost:61616</div> |
| <p> |
| The sample Axis2 server will pick up the message from the JMS queue and print the |
| following log entry. |
| </p> |
| <div class="consoleOutput">Accepted order for : 18406 stocks of MSFT at $ 83.58806051152119</div> |
| </subsection> |
| </section> |
| <p><a href="../samples.html">Back to Catalog</a></p> |
| </body> |
| </document> |