| <?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 269</title> |
| </properties> |
| <body> |
| <section name="Sample 269:Introduction to AMQP Transport"> |
| <div class="xmlConf"> |
| <definitions xmlns="http://ws.apache.org/ns/synapse"> |
| |
| <proxy name="ConsumerProxy" transports="amqp"> |
| <target> |
| <inSequence> |
| <property action="set" name="OUT_ONLY" value="true"/> |
| <log level="custom"> |
| <property name="status" value="At ConsumerProxy"/> |
| </log> |
| <log level="full"/> |
| <drop/> |
| </inSequence> |
| <outSequence> |
| <send/> |
| </outSequence> |
| </target> |
| <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/> |
| <parameter name="transport.amqp.ConnectionFactoryName">consumer</parameter> |
| <parameter name="transport.amqp.QueueName">ConsumerProxy</parameter> |
| </proxy> |
| |
| </definitions> |
| </div> |
| <subsection name="Objective"> |
| <p> |
| Demonstrate the AMQP transport of Synapse. |
| </p> |
| </subsection> |
| <subsection name="Pre-requisites"> |
| <p> |
| <ul> |
| <li> |
| <a href="http://www.rabbitmq.com/java-client.html" >Download</a> the RabbitMQ |
| Java client library and copy it into Synapse class path (SYNAPSE_HOME/lib). |
| </li> |
| <li> |
| <a href="http://www.rabbitmq.com/" >Download</a> and install the RabbitMQ AMQP broker. |
| Then start the broker on its default port(5672). |
| </li> |
| <li> |
| Uncomment the AMQP transport listener section in axis2.xml(repository/conf/axis2.xml). |
| If you are running the AMQP broker on a port other than the default port, |
| configure the connection factory definitions in AMQP transport listener appropriately. |
| </li> |
| <li> |
| Start Synapse using the configuration numbered 269 (repository/conf/sample/synapse_sample_269.xml) |
| <div class="command"> |
| Unix/Linux: sh synapse.sh -sample 269<br/> |
| Windows: synapse.bat -sample 269 |
| </div> |
| </li> |
| </ul> |
| </p> |
| </subsection> |
| <subsection name="Executing the Client"> |
| <p> |
| In this sample we are using a proxy service exposed over AMQP (note the transports=amqp |
| attribute). If you check the WSDL of the proxy service using a web browser, you |
| will notice that it only has AMQP endpoints. |
| </p> |
| <p> |
| Run the sample RabbitMQ AMQP client by switching to the samples/axis2Client directory and |
| executing the following command. Other options that can be passed into the RabbitMQ |
| client can be found by just executing 'ant'. |
| </p> |
| <div class="command">ant rabbitmqclient -Damqpmode=producer -DqueueName=ConsumerProxy -DpayLoad=IBM</div> |
| <p> |
| This will send a plain XML formatted place order request to a queue in the RabbitMQ |
| broker. The queue is named 'ConsumerProxy'. Synapse will be polling on this queue for |
| any incoming messages so it will pick up the request. A message similar to following |
| will be logged on the console indicating that the message has been received at the |
| proxy service. |
| </p> |
| <div class="consoleOutput">2013-07-30 17:00:56,687 [-] [pool-11-thread-5] INFO LogMediator status = At ConsumerProxy</div> |
| <div class="consoleOutput"> |
| 22013-07-30 17:00:56,688 [-] [pool-11-thread-5] INFO LogMediator To: null, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><m:placeOrder xmlns:m="http://services.samples"> |
| <m:order> |
| <m:price>163.00923364424872</m:price> |
| <m:quantity>6620</m:quantity> |
| <m:symbol>IBM</m:symbol> |
| </m:order> |
| </m:placeOrder></soapenv:Body></soapenv:Envelope> |
| </div> |
| |
| <p> |
| Note that the operation is out-only and no response is sent back to the client. |
| The content type of the message can be configured using the parameter |
| transport.amqp.ContentType and by default this is assumed to be application/xml. |
| </p> |
| <div class="xmlConf"><parameter name="transport.amqp.ConnectionFactoryName">consumer</parameter></div> |
| <p> |
| Above parameter defines the name of the connection factory that should be used. |
| If a specific connection factory is not given the default connection factory will be used. |
| </p> |
| <div class="xmlConf"><parameter name="transport.amqp.QueueName">ConsumerProxy</parameter></div> |
| <p> |
| Above parameter defines the queue to which the proxy service will connect and start to listen. |
| The other configuration parameters and more examples of AMQP transport can be |
| found in the AMQP transport documentation. |
| </p> |
| </subsection> |
| </section> |
| <p><a href="../samples.html">Back to Catalog</a></p> |
| </body> |
| </document> |