blob: 64d7a7fb3a1408c27545b4a64280b025b4106e0e [file]
<?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">
&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
&lt;proxy name="ConsumerProxy" transports="amqp"&gt;
&lt;target&gt;
&lt;inSequence&gt;
&lt;property action="set" name="OUT_ONLY" value="true"/&gt;
&lt;log level="custom"&gt;
&lt;property name="status" value="At ConsumerProxy"/&gt;
&lt;/log&gt;
&lt;log level="full"/&gt;
&lt;drop/&gt;
&lt;/inSequence&gt;
&lt;outSequence&gt;
&lt;send/&gt;
&lt;/outSequence&gt;
&lt;/target&gt;
&lt;publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/&gt;
&lt;parameter name="transport.amqp.ConnectionFactoryName"&gt;consumer&lt;/parameter&gt;
&lt;parameter name="transport.amqp.QueueName"&gt;ConsumerProxy&lt;/parameter&gt;
&lt;/proxy&gt;
&lt;/definitions&gt;
</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: &lt;?xml version='1.0' encoding='utf-8'?&gt;&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soapenv:Body&gt;&lt;m:placeOrder xmlns:m="http://services.samples"&gt;
&lt;m:order&gt;
&lt;m:price&gt;163.00923364424872&lt;/m:price&gt;
&lt;m:quantity&gt;6620&lt;/m:quantity&gt;
&lt;m:symbol&gt;IBM&lt;/m:symbol&gt;
&lt;/m:order&gt;
&lt;/m:placeOrder&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;
</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">&lt;parameter name=&quot;transport.amqp.ConnectionFactoryName&quot;&gt;consumer&lt;/parameter&gt;</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">&lt;parameter name=&quot;transport.amqp.QueueName&quot;&gt;ConsumerProxy&lt;/parameter&gt;</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>