| <?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 250</title> |
| </properties> |
| <body> |
| <section name="Sample 250:Introduction to Transport Switching - JMS to HTTP/S "> |
| <div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse"> |
| |
| <proxy name="StockQuoteProxy" transports="jms"> |
| <target> |
| <inSequence> |
| <property action="set" name="OUT_ONLY" value="true"/> |
| </inSequence> |
| <endpoint> |
| <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> |
| </endpoint> |
| <outSequence> |
| <send/> |
| </outSequence> |
| </target> |
| <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/> |
| <parameter name="transport.jms.ContentType"> |
| <rules> |
| <jmsProperty>contentType</jmsProperty> |
| <default>application/xml</default> |
| </rules> |
| </parameter> |
| </proxy> |
| |
| </definitions></div> |
| <subsection name="Objective"> |
| <p> |
| Demonstrate the ability of Synapse to perform transport switching (i.e. receiving |
| messages over one transport and forwarding them over a different transport) |
| </p> |
| </subsection> |
| <subsection name="Pre-requisites"> |
| <p> |
| <ul> |
| <li> |
| Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2 |
| </li> |
| <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 Synapse (Refer |
| <a href="setup/jms.html#listener">JMS setup guide</a> for more details) |
| </li> |
| <li> |
| Start Synapse using the configuration numbered 250 (repository/conf/sample/synapse_sample_250.xml) |
| <div class="command"> |
| Unix/Linux: sh synapse.sh -sample 250<br/> |
| Windows: synapse.bat -sample 250 |
| </div> |
| </li> |
| </ul> |
| </p> |
| </subsection> |
| <subsection name="Executing the Client"> |
| <p> |
| In this sample we are using a proxy service exposed over JMS (note the transports=jms |
| attribute). If you check the WSDL of the proxy service using a web browser you |
| will notice that it only has JMS endpoints. |
| </p> |
| <p> |
| Run the sample JMS client by switching to the samples/axis2Client directory and |
| executing the following command. |
| </p> |
| <div class="command">ant jmsclient -Djms_type=pox -Djms_dest=dynamicQueues/StockQuoteProxy -Djms_payload=MSFT</div> |
| <p> |
| This will send a plain XML formatted place order request to a JMS queue named |
| 'StockQuoteProxy'. Synapse will be polling on this queue for any incoming messages |
| so it will pick up the request. If you run Synapse in the DEBUG mode, following |
| entry will be printed on the console. |
| </p> |
| <div class="consoleOutput">[JMSWorker-1] DEBUG ProxyServiceMessageReceiver -Proxy Service StockQuoteProxy received a new message...</div> |
| <p> |
| Then Synapse will mediate the request through the service bus and forward it to |
| the sample Axis2 server over HTTP. Axis2 server will print the following entry |
| on the console when it receives the request. |
| </p> |
| <div class="consoleOutput">Accepted order for : 16517 stocks of MSFT at $ 169.14622538721846</div> |
| <p> |
| Note that the operation is out-only and no response is sent back to the client. |
| The transport.jms.ContentType property is necessary to allow the JMS transport |
| to determine the content type of incoming messages. With the given configuration |
| it will first try to read the content type from the 'contentType' message property |
| and fall back to 'application/xml' (i.e. POX) if this property is not set. Note |
| that the JMS client used in this example doesn't send any content type |
| information. |
| </p> |
| <p> |
| It is also important to note that the name of the source JMS queue is same as the |
| name of the proxy service (StockQuoteProxy). This is the default behavior of |
| Synapse. Each proxy service by default listens on a JMS queue which has the same |
| name as the service. It is possible to instruct a JMS proxy service to listen to |
| an already existing destination without creating a new one. To do this, use the |
| parameter elements on the proxy service definition to specify the destination |
| and connection factory information. An example is given below. |
| </p> |
| <div class="xmlConf"><parameter name="transport.jms.Destination">dynamicTopics/something.TestTopic</parameter></div> |
| <p> |
| With the above parameter in the proxy configuration, proxy service will listen |
| on a JMS topic named 'something.TestTopic' for incoming requests. |
| </p> |
| </subsection> |
| </section> |
| <p><a href="../samples.html">Back to Catalog</a></p> |
| </body> |
| </document> |