You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by us...@apache.org on 2011/12/20 07:21:16 UTC
svn commit: r1221113 - in /synapse/branches/2.1:
modules/core/src/main/java/org/apache/synapse/mediators/
repository/conf/sample/ repository/conf/sample/resources/recipients/
src/site/xdoc/
Author: uswick
Date: Tue Dec 20 06:21:16 2011
New Revision: 1221113
URL: http://svn.apache.org/viewvc?rev=1221113&view=rev
Log:
committing SYNAPSE-808 sample updates (recipient list)
Added:
synapse/branches/2.1/repository/conf/sample/resources/recipients/
synapse/branches/2.1/repository/conf/sample/resources/recipients/EP_LIST
synapse/branches/2.1/repository/conf/sample/synapse_sample_61.xml
synapse/branches/2.1/repository/conf/sample/synapse_sample_62.xml
synapse/branches/2.1/repository/conf/sample/synapse_sample_63.xml
Modified:
synapse/branches/2.1/modules/core/src/main/java/org/apache/synapse/mediators/GetPropertyFunction.java
synapse/branches/2.1/src/site/xdoc/Synapse_Samples.xml
Modified: synapse/branches/2.1/modules/core/src/main/java/org/apache/synapse/mediators/GetPropertyFunction.java
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/modules/core/src/main/java/org/apache/synapse/mediators/GetPropertyFunction.java?rev=1221113&r1=1221112&r2=1221113&view=diff
==============================================================================
--- synapse/branches/2.1/modules/core/src/main/java/org/apache/synapse/mediators/GetPropertyFunction.java (original)
+++ synapse/branches/2.1/modules/core/src/main/java/org/apache/synapse/mediators/GetPropertyFunction.java Tue Dec 20 06:21:16 2011
@@ -38,6 +38,11 @@ import org.jaxen.FunctionCallException;
import org.jaxen.Navigator;
import org.jaxen.function.StringFunction;
+import javax.activation.DataHandler;
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.List;
@@ -319,7 +324,24 @@ public class GetPropertyFunction impleme
}
} else if (propEntry.getValue() != null) {
if (propEntry.getValue() instanceof OMText) {
- return ((OMText) propEntry.getValue()).getText();
+ OMText omText = (OMText) propEntry.getValue();
+ DataHandler dh = (DataHandler) omText.getDataHandler();
+ if (omText.getDataHandler() != null) {
+ try {
+ InputStreamReader streamReader = new InputStreamReader(dh.getInputStream());
+ BufferedReader stringReader = new BufferedReader(streamReader);
+ String omTextString = NULL_STRING;
+ String tempStr;
+ while ((tempStr = stringReader.readLine()) != null) {
+ omTextString = omTextString + tempStr;
+ }
+ return omTextString;
+ } catch (IOException e) {
+ return NULL_STRING;
+ }
+ } else {
+ omText.getText();
+ }
}
return propEntry.getValue().toString();
}
Added: synapse/branches/2.1/repository/conf/sample/resources/recipients/EP_LIST
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/repository/conf/sample/resources/recipients/EP_LIST?rev=1221113&view=auto
==============================================================================
--- synapse/branches/2.1/repository/conf/sample/resources/recipients/EP_LIST (added)
+++ synapse/branches/2.1/repository/conf/sample/resources/recipients/EP_LIST Tue Dec 20 06:21:16 2011
@@ -0,0 +1 @@
+http://localhost:9001/services/SimpleStockQuoteService,http://localhost:9002/services/SimpleStockQuoteService,http://localhost:9003/services/SimpleStockQuoteService
Added: synapse/branches/2.1/repository/conf/sample/synapse_sample_61.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/repository/conf/sample/synapse_sample_61.xml?rev=1221113&view=auto
==============================================================================
--- synapse/branches/2.1/repository/conf/sample/synapse_sample_61.xml (added)
+++ synapse/branches/2.1/repository/conf/sample/synapse_sample_61.xml Tue Dec 20 06:21:16 2011
@@ -0,0 +1,55 @@
+<?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.
+ -->
+
+<!--Routing message to 3 static recipients-->
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <sequence name="main" onError="errorHandler">
+ <in>
+ <property name="OUT_ONLY" value="true" />
+ <property name="FORCE_SC_ACCEPTED" scope="axis2" value="true" />
+ <send>
+ <endpoint>
+ <!--List of Recipients (static)-->
+ <recipientlist>
+ <endpoint>
+ <address uri="http://localhost:9001/services/SimpleStockQuoteService"/>
+ </endpoint>
+ <endpoint>
+ <address uri="http://localhost:9002/services/SimpleStockQuoteService"/>
+ </endpoint>
+ <endpoint>
+ <address uri="http://localhost:9003/services/SimpleStockQuoteService"/>
+ </endpoint>
+ </recipientlist>
+ </endpoint>
+ </send>
+ <drop/>
+ </in>
+ </sequence>
+
+ <sequence name="errorHandler">
+ <makefault response="true">
+ <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
+ <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER."/>
+ </makefault>
+ <send/>
+ </sequence>
+</definitions>
Added: synapse/branches/2.1/repository/conf/sample/synapse_sample_62.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/repository/conf/sample/synapse_sample_62.xml?rev=1221113&view=auto
==============================================================================
--- synapse/branches/2.1/repository/conf/sample/synapse_sample_62.xml (added)
+++ synapse/branches/2.1/repository/conf/sample/synapse_sample_62.xml Tue Dec 20 06:21:16 2011
@@ -0,0 +1,54 @@
+<?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.
+ -->
+<!--Routing message to dynamic recipients-->
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) -->
+ <registry provider="org.apache.synapse.registry.url.SimpleURLRegistry">
+ <!-- the root property of the simple URL registry helps resolve a resource URL as root + key -->
+ <parameter name="root">file:repository/conf/sample/resources/</parameter>
+ <!-- all resources loaded from the URL registry would be cached for this number of milli seconds -->
+ <parameter name="cachableDuration">15000</parameter>
+ </registry>
+
+ <sequence name="main" onError="errorHandler">
+ <in>
+ <property name="OUT_ONLY" value="true" />
+ <property name="FORCE_SC_ACCEPTED" scope="axis2" value="true" />
+ <!--Dynamic Reclipient List-->
+ <send>
+ <endpoint>
+ <recipientlist>
+ <endpoints value="{get-property('registry','recipients/EP_LIST')}"/>
+ </recipientlist>
+ </endpoint>
+ </send>
+ <drop/>
+ </in>
+ </sequence>
+
+ <sequence name="errorHandler">
+ <makefault response="true">
+ <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
+ <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER."/>
+ </makefault>
+ <send/>
+ </sequence>
+</definitions>
Added: synapse/branches/2.1/repository/conf/sample/synapse_sample_63.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/repository/conf/sample/synapse_sample_63.xml?rev=1221113&view=auto
==============================================================================
--- synapse/branches/2.1/repository/conf/sample/synapse_sample_63.xml (added)
+++ synapse/branches/2.1/repository/conf/sample/synapse_sample_63.xml Tue Dec 20 06:21:16 2011
@@ -0,0 +1,63 @@
+<?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.
+ -->
+<!--Route message to dynamic Recipients and aggregate their responses-->
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) -->
+ <registry provider="org.apache.synapse.registry.url.SimpleURLRegistry">
+ <!-- the root property of the simple URL registry helps resolve a resource URL as root + key -->
+ <parameter name="root">file:repository/conf/sample/resources/</parameter>
+ <!-- all resources loaded from the URL registry would be cached for this number of milli seconds -->
+ <parameter name="cachableDuration">15000</parameter>
+ </registry>
+
+ <sequence name="main" onError="errorHandler">
+ <in>
+ <!--Dynamic Recipient List-->
+ <send>
+ <endpoint>
+ <recipientlist>
+ <endpoints value="{get-property('registry','recipients/EP_LIST')}"/>
+ </recipientlist>
+ </endpoint>
+ </send>
+ <drop/>
+ </in>
+
+ <out>
+ <log level="full"/>
+ <!--Aggregate responses-->
+ <aggregate>
+ <onComplete xmlns:m0="http://services.samples"
+ expression="//m0:getQuoteResponse">
+ <send/>
+ </onComplete>
+ </aggregate>
+ </out>
+ </sequence>
+
+ <sequence name="errorHandler">
+ <makefault response="true">
+ <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
+ <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER."/>
+ </makefault>
+ <send/>
+ </sequence>
+</definitions>
Modified: synapse/branches/2.1/src/site/xdoc/Synapse_Samples.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/Synapse_Samples.xml?rev=1221113&r1=1221112&r2=1221113&view=diff
==============================================================================
--- synapse/branches/2.1/src/site/xdoc/Synapse_Samples.xml (original)
+++ synapse/branches/2.1/src/site/xdoc/Synapse_Samples.xml Tue Dec 20 06:21:16 2011
@@ -173,7 +173,12 @@
<a href="#Sample59">Sample 59: Weighted load balancing between 3 endpoints</a></li>
<li>
<a href="#Sample60">Sample 60: Service dynamic load balancing between 2 Service nodes</a></li>
-</ul></li>
+<li>
+<a href="#Sample60">Sample 61: Routing a message to a static list of recipients</a></li>
+<li>
+<a href="#Sample61">Sample 62: Routing a message to a dynamic list of recipients</a></li>
+<li>
+<a href="#Sample62">Sample 63: Routing a message to a dynamic list of recipients and aggregating the responses</a></li></ul></li>
<li>
<a href="#MessageMediationQoS">Quality of Service addition or deduction samples in message mediation</a>
<ul>
@@ -1968,6 +1973,190 @@ ant loadbalancefailover -Di=100 -Dtrpurl
For the sake of simplicity, we have shown how to run this sample for one clustering domain at a time. However, you can make a copy of the axis2Server directory, and setup both domains simultaneously, and run the sample client to see how the requests are load balanced in a round-robin manner within each clustering domain.
</p>
+
+<h2><a name="Sample61">Sample 61: Routing a message to a static list of recipients</a></h2>
+<pre xml:space="preserve">
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <sequence name="main" onError="errorHandler">
+ <in>
+ <send>
+ <endpoint>
+ <!--List of Recipients (static)-->
+ <recipientlist>
+ <endpoint>
+ <address uri="http://localhost:9001/services/SimpleStockQuoteService"/>
+ </endpoint>
+ <endpoint>
+ <address uri="http://localhost:9002/services/SimpleStockQuoteService"/>
+ </endpoint>
+ <endpoint>
+ <address uri="http://localhost:9003/services/SimpleStockQuoteService"/>
+ </endpoint>
+ </recipientlist>
+ </endpoint>
+ </send>
+ <drop/>
+ </in>
+
+ <out>
+ <log level="full"/>
+ <drop/>
+ </out>
+ </sequence>
+
+ <sequence name="errorHandler">
+ <makefault response="true">
+ <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
+ <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER."/>
+ </makefault>
+ <send/>
+ </sequence>
+</definitions>
+</pre>
+<p><strong>Objective: Demonstrate message routing to a set of
+static endpoints</strong> </p>
+
+<p><strong>Prerequisites:</strong> </p>
+
+<p>Start ESB with sample configuration 61. (i.e. synapse -sample 61) </p>
+
+<p>Deploy the SimpleStockQuoteService and start three instances of sample Axis2 server as mentioned in sample 52.</p>
+
+<p>Above configuration routes a cloned copy of a message to each recipient defined within the static recipient list.
+<br/>To test this, run the stockquote client to send an out-only message: </p>
+<pre xml:space="preserve">ant stockquote -Dmode=placeorder -Dtrpurl=http://localhost:8280/</pre>
+
+<p>This client sends a request to the SimpleStockQuoteService through the
+ESB. ESB will create cloned copies of the message and route to the three endpoints
+mentioned in the configuration. SimpleStockQuoteService prints the details of the placed
+order. If you examine the console output of each server, you can see that requests are
+processed by the three servers as follows: </p>
+<pre xml:space="preserve">Accepted order #1 for : 15738 stocks of IBM at $ 185.51155223506518
+</pre>
+
+<p>Now shutdown MyServer1 and resend the request. You will observe that requests are still processed by MyServer2 and MyServer3.</p>
+
+<h2><a name="Sample62">Sample 62: Routing a message to a dynamic list of recipients</a></h2>
+<pre xml:space="preserve">
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) -->
+ <registry provider="org.apache.synapse.registry.url.SimpleURLRegistry">
+ <!-- the root property of the simple URL registry helps resolve a resource URL as root + key -->
+ <parameter name="root">file:repository/conf/sample/resources/</parameter>
+ <!-- all resources loaded from the URL registry would be cached for this number of milli seconds -->
+ <parameter name="cachableDuration">15000</parameter>
+ </registry>
+
+ <sequence name="main" onError="errorHandler">
+ <in>
+ <property name="OUT_ONLY" value="true" />
+ <property name="FORCE_SC_ACCEPTED" scope="axis2" value="true" />
+ <!--Dynamic Reclipient List-->
+ <send>
+ <endpoint>
+ <recipientlist>
+ <endpoints value="{get-property('registry','recipients/EP_LIST')}"/>
+ </recipientlist>
+ </endpoint>
+ </send>
+ <drop/>
+ </in>
+ </sequence>
+
+ <sequence name="errorHandler">
+ <makefault response="true">
+ <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
+ <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER."/>
+ </makefault>
+ <send/>
+ </sequence>
+</definitions>
+</pre>
+<p><strong>Objective: Demonstrate message routing to a set of
+dynamic endpoints</strong> </p>
+
+<p><strong>Prerequisites:</strong> </p>
+
+<p>Start ESB with sample configuration 62. (i.e. synapse -sample 62) </p>
+
+<p>Deploy the SimpleStockQuoteService and start three instances of sample Axis2 server as mentioned in sample 52.</p>
+
+<p>This sample does the same thing as in sample 60. The difference is that unlike in sample 60, this sample defines
+the endpoints as a dynamic list of recipients.
+<br/>To test this, run the stockquote client to send an out-only message: </p>
+<pre xml:space="preserve">ant stockquote -Dmode=placeorder -Dtrpurl=http://localhost:8280/</pre>
+
+<p>The behaviour of this sample should be similar to that of sample 60</p>
+
+<h2><a name="Sample63">Sample 63: Routing a message to a dynamic list of recipients and aggregating responses</a></h2>
+<pre xml:space="preserve">
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) -->
+ <registry provider="org.apache.synapse.registry.url.SimpleURLRegistry">
+ <!-- the root property of the simple URL registry helps resolve a resource URL as root + key -->
+ <parameter name="root">file:repository/conf/sample/resources/</parameter>
+ <!-- all resources loaded from the URL registry would be cached for this number of milli seconds -->
+ <parameter name="cachableDuration">15000</parameter>
+ </registry>
+
+ <sequence name="main" onError="errorHandler">
+ <in>
+ <!--Dynamic Recipient List-->
+ <send>
+ <endpoint>
+ <recipientlist>
+ <endpoints value="{get-property('registry','recipients/EP_LIST')}"/>
+ </recipientlist>
+ </endpoint>
+ </send>
+ <drop/>
+ </in>
+
+ <out>
+ <log level="full"/>
+ <!--Aggregate responses-->
+ <aggregate>
+ <onComplete xmlns:m0="http://services.samples"
+ expression="//m0:getQuoteResponse">
+ <send/>
+ </onComplete>
+ </aggregate>
+ </out>
+ </sequence>
+
+ <sequence name="errorHandler">
+ <makefault response="true">
+ <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
+ <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER."/>
+ </makefault>
+ <send/>
+ </sequence>
+</definitions>
+</pre>
+<p><strong>Objective: Demonstrate message routing to a set of
+dynamic endpoints and aggregate responses</strong> </p>
+
+<p><strong>Prerequisites:</strong> </p>
+
+<p>Start ESB with sample configuration 63. (i.e. synapse -sample 63) </p>
+
+<p>Deploy the SimpleStockQuoteService and start three instances of sample Axis2 server as mentioned in sample 52.</p>
+
+<p>Above configuration routes a cloned copy of a message to each recipient defined within the dynamic recipient list.
+Each recipient will respond back with a stock quote. When all the responses appear to synapse those resonses will be
+aggregated to form the resultant response which will be sent back to the client.
+<br/>To test this, invoke the client as follows: </p>
+<pre xml:space="preserve">ant stockquote -Dtrpurl=http://localhost:8280/</pre>
+
+<p>If you sent your client request through a TCP based conversation monitoring tool such as TCPMon, you will notice the
+structrue of the aggregated response message.</p>
+
+
<h1><a name="MessageMediationQoS" id="MessageMediationQoS">Quality of Service addition or deduction samples in message mediation</a> </h1>
<h2>
<a name="Sample100" id="Sample100">Sample 100: Using WS-Security for outgoing messages</a></h2>
Re: svn commit: r1221113 - in /synapse/branches/2.1:
modules/core/src/main/java/org/apache/synapse/mediators/ repository/conf/sample/
repository/conf/sample/resources/recipients/ src/site/xdoc/
Posted by Udayanga Wickramasinghe <ud...@wso2.com>.
On Tue, Dec 20, 2011 at 3:00 PM, Hiranya Jayathilaka
<hi...@gmail.com>wrote:
> This should go into trunk too. Please commit everything to both SVN
> locations until we are done with this release.
>
> i have committed the changes to trunk as well..guess something might have
gone wrong with the commit mail..
regards,
udayanga--
*Udayanga Wickramasinghe*
Software Engineer; WSO2 Inc.; http://wso2.com,
*email: **udayanga@wso2.com* <ud...@wso2.com>* cell: +94 (77) 983-4365
blog: **http://udayangawiki.blogspot.com*<http://udayangawiki.blogspot.com/>
*
twitter: **http://twitter.com/udayanga_wick*<http://twitter.com/udayanga_wick>
*
*
Re: svn commit: r1221113 - in /synapse/branches/2.1:
modules/core/src/main/java/org/apache/synapse/mediators/ repository/conf/sample/
repository/conf/sample/resources/recipients/ src/site/xdoc/
Posted by Hiranya Jayathilaka <hi...@gmail.com>.
This should go into trunk too. Please commit everything to both SVN
locations until we are done with this release.
Thanks,
Hiranya
On Tue, Dec 20, 2011 at 11:51 AM, <us...@apache.org> wrote:
> Author: uswick
> Date: Tue Dec 20 06:21:16 2011
> New Revision: 1221113
>
> URL: http://svn.apache.org/viewvc?rev=1221113&view=rev
> Log:
> committing SYNAPSE-808 sample updates (recipient list)
>
> Added:
> synapse/branches/2.1/repository/conf/sample/resources/recipients/
> synapse/branches/2.1/repository/conf/sample/resources/recipients/EP_LIST
> synapse/branches/2.1/repository/conf/sample/synapse_sample_61.xml
> synapse/branches/2.1/repository/conf/sample/synapse_sample_62.xml
> synapse/branches/2.1/repository/conf/sample/synapse_sample_63.xml
> Modified:
>
> synapse/branches/2.1/modules/core/src/main/java/org/apache/synapse/mediators/GetPropertyFunction.java
> synapse/branches/2.1/src/site/xdoc/Synapse_Samples.xml
>
> Modified:
> synapse/branches/2.1/modules/core/src/main/java/org/apache/synapse/mediators/GetPropertyFunction.java
> URL:
> http://svn.apache.org/viewvc/synapse/branches/2.1/modules/core/src/main/java/org/apache/synapse/mediators/GetPropertyFunction.java?rev=1221113&r1=1221112&r2=1221113&view=diff
>
> ==============================================================================
> ---
> synapse/branches/2.1/modules/core/src/main/java/org/apache/synapse/mediators/GetPropertyFunction.java
> (original)
> +++
> synapse/branches/2.1/modules/core/src/main/java/org/apache/synapse/mediators/GetPropertyFunction.java
> Tue Dec 20 06:21:16 2011
> @@ -38,6 +38,11 @@ import org.jaxen.FunctionCallException;
> import org.jaxen.Navigator;
> import org.jaxen.function.StringFunction;
>
> +import javax.activation.DataHandler;
> +import java.io.BufferedInputStream;
> +import java.io.BufferedReader;
> +import java.io.IOException;
> +import java.io.InputStreamReader;
> import java.text.Format;
> import java.text.SimpleDateFormat;
> import java.util.List;
> @@ -319,7 +324,24 @@ public class GetPropertyFunction impleme
> }
> } else if (propEntry.getValue() != null) {
> if (propEntry.getValue() instanceof OMText) {
> - return ((OMText) propEntry.getValue()).getText();
> + OMText omText = (OMText) propEntry.getValue();
> + DataHandler dh = (DataHandler)
> omText.getDataHandler();
> + if (omText.getDataHandler() != null) {
> + try {
> + InputStreamReader streamReader = new
> InputStreamReader(dh.getInputStream());
> + BufferedReader stringReader = new
> BufferedReader(streamReader);
> + String omTextString = NULL_STRING;
> + String tempStr;
> + while ((tempStr =
> stringReader.readLine()) != null) {
> + omTextString = omTextString + tempStr;
> + }
> + return omTextString;
> + } catch (IOException e) {
> + return NULL_STRING;
> + }
> + } else {
> + omText.getText();
> + }
> }
> return propEntry.getValue().toString();
> }
>
> Added:
> synapse/branches/2.1/repository/conf/sample/resources/recipients/EP_LIST
> URL:
> http://svn.apache.org/viewvc/synapse/branches/2.1/repository/conf/sample/resources/recipients/EP_LIST?rev=1221113&view=auto
>
> ==============================================================================
> ---
> synapse/branches/2.1/repository/conf/sample/resources/recipients/EP_LIST
> (added)
> +++
> synapse/branches/2.1/repository/conf/sample/resources/recipients/EP_LIST
> Tue Dec 20 06:21:16 2011
> @@ -0,0 +1 @@
> +
> http://localhost:9001/services/SimpleStockQuoteService,http://localhost:9002/services/SimpleStockQuoteService,http://localhost:9003/services/SimpleStockQuoteService
>
> Added: synapse/branches/2.1/repository/conf/sample/synapse_sample_61.xml
> URL:
> http://svn.apache.org/viewvc/synapse/branches/2.1/repository/conf/sample/synapse_sample_61.xml?rev=1221113&view=auto
>
> ==============================================================================
> --- synapse/branches/2.1/repository/conf/sample/synapse_sample_61.xml
> (added)
> +++ synapse/branches/2.1/repository/conf/sample/synapse_sample_61.xml Tue
> Dec 20 06:21:16 2011
> @@ -0,0 +1,55 @@
> +<?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.
> + -->
> +
> +<!--Routing message to 3 static recipients-->
> +<definitions xmlns="http://ws.apache.org/ns/synapse">
> +
> + <sequence name="main" onError="errorHandler">
> + <in>
> + <property name="OUT_ONLY" value="true" />
> + <property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"
> />
> + <send>
> + <endpoint>
> + <!--List of Recipients (static)-->
> + <recipientlist>
> + <endpoint>
> + <address uri="
> http://localhost:9001/services/SimpleStockQuoteService"/>
> + </endpoint>
> + <endpoint>
> + <address uri="
> http://localhost:9002/services/SimpleStockQuoteService"/>
> + </endpoint>
> + <endpoint>
> + <address uri="
> http://localhost:9003/services/SimpleStockQuoteService"/>
> + </endpoint>
> + </recipientlist>
> + </endpoint>
> + </send>
> + <drop/>
> + </in>
> + </sequence>
> +
> + <sequence name="errorHandler">
> + <makefault response="true">
> + <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope"
> value="tns:Receiver"/>
> + <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER."/>
> + </makefault>
> + <send/>
> + </sequence>
> +</definitions>
>
> Added: synapse/branches/2.1/repository/conf/sample/synapse_sample_62.xml
> URL:
> http://svn.apache.org/viewvc/synapse/branches/2.1/repository/conf/sample/synapse_sample_62.xml?rev=1221113&view=auto
>
> ==============================================================================
> --- synapse/branches/2.1/repository/conf/sample/synapse_sample_62.xml
> (added)
> +++ synapse/branches/2.1/repository/conf/sample/synapse_sample_62.xml Tue
> Dec 20 06:21:16 2011
> @@ -0,0 +1,54 @@
> +<?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.
> + -->
> +<!--Routing message to dynamic recipients-->
> +<definitions xmlns="http://ws.apache.org/ns/synapse">
> +
> + <!-- the SimpleURLRegistry allows access to a URL based registry
> (e.g. file:/// or http://) -->
> + <registry
> provider="org.apache.synapse.registry.url.SimpleURLRegistry">
> + <!-- the root property of the simple URL registry helps resolve a
> resource URL as root + key -->
> + <parameter
> name="root">file:repository/conf/sample/resources/</parameter>
> + <!-- all resources loaded from the URL registry would be cached
> for this number of milli seconds -->
> + <parameter name="cachableDuration">15000</parameter>
> + </registry>
> +
> + <sequence name="main" onError="errorHandler">
> + <in>
> + <property name="OUT_ONLY" value="true" />
> + <property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"
> />
> + <!--Dynamic Reclipient List-->
> + <send>
> + <endpoint>
> + <recipientlist>
> + <endpoints
> value="{get-property('registry','recipients/EP_LIST')}"/>
> + </recipientlist>
> + </endpoint>
> + </send>
> + <drop/>
> + </in>
> + </sequence>
> +
> + <sequence name="errorHandler">
> + <makefault response="true">
> + <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope"
> value="tns:Receiver"/>
> + <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER."/>
> + </makefault>
> + <send/>
> + </sequence>
> +</definitions>
>
> Added: synapse/branches/2.1/repository/conf/sample/synapse_sample_63.xml
> URL:
> http://svn.apache.org/viewvc/synapse/branches/2.1/repository/conf/sample/synapse_sample_63.xml?rev=1221113&view=auto
>
> ==============================================================================
> --- synapse/branches/2.1/repository/conf/sample/synapse_sample_63.xml
> (added)
> +++ synapse/branches/2.1/repository/conf/sample/synapse_sample_63.xml Tue
> Dec 20 06:21:16 2011
> @@ -0,0 +1,63 @@
> +<?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.
> + -->
> +<!--Route message to dynamic Recipients and aggregate their responses-->
> +<definitions xmlns="http://ws.apache.org/ns/synapse">
> +
> + <!-- the SimpleURLRegistry allows access to a URL based registry
> (e.g. file:/// or http://) -->
> + <registry
> provider="org.apache.synapse.registry.url.SimpleURLRegistry">
> + <!-- the root property of the simple URL registry helps resolve a
> resource URL as root + key -->
> + <parameter
> name="root">file:repository/conf/sample/resources/</parameter>
> + <!-- all resources loaded from the URL registry would be cached
> for this number of milli seconds -->
> + <parameter name="cachableDuration">15000</parameter>
> + </registry>
> +
> + <sequence name="main" onError="errorHandler">
> + <in>
> + <!--Dynamic Recipient List-->
> + <send>
> + <endpoint>
> + <recipientlist>
> + <endpoints
> value="{get-property('registry','recipients/EP_LIST')}"/>
> + </recipientlist>
> + </endpoint>
> + </send>
> + <drop/>
> + </in>
> +
> + <out>
> + <log level="full"/>
> + <!--Aggregate responses-->
> + <aggregate>
> + <onComplete xmlns:m0="http://services.samples"
> + expression="//m0:getQuoteResponse">
> + <send/>
> + </onComplete>
> + </aggregate>
> + </out>
> + </sequence>
> +
> + <sequence name="errorHandler">
> + <makefault response="true">
> + <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope"
> value="tns:Receiver"/>
> + <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER."/>
> + </makefault>
> + <send/>
> + </sequence>
> +</definitions>
>
> Modified: synapse/branches/2.1/src/site/xdoc/Synapse_Samples.xml
> URL:
> http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/Synapse_Samples.xml?rev=1221113&r1=1221112&r2=1221113&view=diff
>
> ==============================================================================
> --- synapse/branches/2.1/src/site/xdoc/Synapse_Samples.xml (original)
> +++ synapse/branches/2.1/src/site/xdoc/Synapse_Samples.xml Tue Dec 20
> 06:21:16 2011
> @@ -173,7 +173,12 @@
> <a href="#Sample59">Sample 59: Weighted load balancing between 3
> endpoints</a></li>
> <li>
> <a href="#Sample60">Sample 60: Service dynamic load balancing between 2
> Service nodes</a></li>
> -</ul></li>
> +<li>
> +<a href="#Sample60">Sample 61: Routing a message to a static list of
> recipients</a></li>
> +<li>
> +<a href="#Sample61">Sample 62: Routing a message to a dynamic list of
> recipients</a></li>
> +<li>
> +<a href="#Sample62">Sample 63: Routing a message to a dynamic list of
> recipients and aggregating the responses</a></li></ul></li>
> <li>
> <a href="#MessageMediationQoS">Quality of Service addition or deduction
> samples in message mediation</a>
> <ul>
> @@ -1968,6 +1973,190 @@ ant loadbalancefailover -Di=100 -Dtrpurl
> For the sake of simplicity, we have shown how to run this sample for one
> clustering domain at a time. However, you can make a copy of the
> axis2Server directory, and setup both domains simultaneously, and run the
> sample client to see how the requests are load balanced in a round-robin
> manner within each clustering domain.
> </p>
>
> +
> +<h2><a name="Sample61">Sample 61: Routing a message to a static list of
> recipients</a></h2>
> +<pre xml:space="preserve">
> +<?xml version="1.0" encoding="UTF-8"?>
> +<definitions xmlns="http://ws.apache.org/ns/synapse">
> +
> + <sequence name="main" onError="errorHandler">
> + <in>
> + <send>
> + <endpoint>
> + <!--List of Recipients (static)-->
> + <recipientlist>
> + <endpoint>
> + <address uri="
> http://localhost:9001/services/SimpleStockQuoteService"/>
> + </endpoint>
> + <endpoint>
> + <address uri="
> http://localhost:9002/services/SimpleStockQuoteService"/>
> + </endpoint>
> + <endpoint>
> + <address uri="
> http://localhost:9003/services/SimpleStockQuoteService"/>
> + </endpoint>
> + </recipientlist>
> + </endpoint>
> + </send>
> + <drop/>
> + </in>
> +
> + <out>
> + <log level="full"/>
> + <drop/>
> + </out>
> + </sequence>
> +
> + <sequence name="errorHandler">
> + <makefault response="true">
> + <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope"
> value="tns:Receiver"/>
> + <reason value="COULDN'T SEND THE MESSAGE TO THE
> SERVER."/>
> + </makefault>
> + <send/>
> + </sequence>
> +</definitions>
> +</pre>
> +<p><strong>Objective: Demonstrate message routing to a set of
> +static endpoints</strong> </p>
> +
> +<p><strong>Prerequisites:</strong> </p>
> +
> +<p>Start ESB with sample configuration 61. (i.e. synapse -sample 61) </p>
> +
> +<p>Deploy the SimpleStockQuoteService and start three instances of sample
> Axis2 server as mentioned in sample 52.</p>
> +
> +<p>Above configuration routes a cloned copy of a message to each
> recipient defined within the static recipient list.
> +<br/>To test this, run the stockquote client to send an out-only message:
> </p>
> +<pre xml:space="preserve">ant stockquote -Dmode=placeorder -Dtrpurl=
> http://localhost:8280/</pre>
> +
> +<p>This client sends a request to the SimpleStockQuoteService through the
> +ESB. ESB will create cloned copies of the message and route to the three
> endpoints
> +mentioned in the configuration. SimpleStockQuoteService prints the
> details of the placed
> +order. If you examine the console output of each server, you can see that
> requests are
> +processed by the three servers as follows: </p>
> +<pre xml:space="preserve">Accepted order #1 for : 15738 stocks of IBM at
> $ 185.51155223506518
> +</pre>
> +
> +<p>Now shutdown MyServer1 and resend the request. You will observe that
> requests are still processed by MyServer2 and MyServer3.</p>
> +
> +<h2><a name="Sample62">Sample 62: Routing a message to a dynamic list of
> recipients</a></h2>
> +<pre xml:space="preserve">
> +<?xml version="1.0" encoding="UTF-8"?>
> +<definitions xmlns="http://ws.apache.org/ns/synapse">
> +
> + <!-- the SimpleURLRegistry allows access to a URL based registry
> (e.g. file:/// or http://) -->
> + <registry
> provider="org.apache.synapse.registry.url.SimpleURLRegistry">
> + <!-- the root property of the simple URL registry helps
> resolve a resource URL as root + key -->
> + <parameter
> name="root">file:repository/conf/sample/resources/</parameter>
> + <!-- all resources loaded from the URL registry would be
> cached for this number of milli seconds -->
> + <parameter
> name="cachableDuration">15000</parameter>
> + </registry>
> +
> + <sequence name="main"
> onError="errorHandler">
> + <in>
> + <property name="OUT_ONLY" value="true"
> />
> + <property name="FORCE_SC_ACCEPTED"
> scope="axis2" value="true" />
> + <!--Dynamic Reclipient List-->
> + <send>
> + <endpoint>
> + <recipientlist>
> + <endpoints
> value="{get-property('registry','recipients/EP_LIST')}"/>
> + </recipientlist>
> + </endpoint>
> + </send>
> + <drop/>
> + </in>
> + </sequence>
> +
> + <sequence name="errorHandler">
> + <makefault response="true">
> + <code xmlns:tns="
> http://www.w3.org/2003/05/soap-envelope"
> value="tns:Receiver"/>
> + <reason value="COULDN'T SEND THE MESSAGE TO THE
> SERVER."/>
> + </makefault>
> + <send/>
> + </sequence>
> +</definitions>
> +</pre>
> +<p><strong>Objective: Demonstrate message routing to a set of
> +dynamic endpoints</strong> </p>
> +
> +<p><strong>Prerequisites:</strong> </p>
> +
> +<p>Start ESB with sample configuration 62. (i.e. synapse -sample 62) </p>
> +
> +<p>Deploy the SimpleStockQuoteService and start three instances of sample
> Axis2 server as mentioned in sample 52.</p>
> +
> +<p>This sample does the same thing as in sample 60. The difference is
> that unlike in sample 60, this sample defines
> +the endpoints as a dynamic list of recipients.
> +<br/>To test this, run the stockquote client to send an out-only message:
> </p>
> +<pre xml:space="preserve">ant stockquote -Dmode=placeorder -Dtrpurl=
> http://localhost:8280/</pre>
> +
> +<p>The behaviour of this sample should be similar to that of sample 60</p>
> +
> +<h2><a name="Sample63">Sample 63: Routing a message to a dynamic list of
> recipients and aggregating responses</a></h2>
> +<pre xml:space="preserve">
> +<definitions xmlns="http://ws.apache.org/ns/synapse">
> +
> + <!-- the SimpleURLRegistry allows access to a URL based registry
> (e.g. file:/// or http://) -->
> + <registry
> provider="org.apache.synapse.registry.url.SimpleURLRegistry">
> + <!-- the root property of the simple URL registry helps
> resolve a resource URL as root + key -->
> + <parameter
> name="root">file:repository/conf/sample/resources/</parameter>
> + <!-- all resources loaded from the URL registry would be
> cached for this number of milli seconds -->
> + <parameter
> name="cachableDuration">15000</parameter>
> + </registry>
> +
> + <sequence name="main"
> onError="errorHandler">
> + <in>
> + <!--Dynamic Recipient List-->
> + <send>
> + <endpoint>
> + <recipientlist>
> + <endpoints
> value="{get-property('registry','recipients/EP_LIST')}"/>
> + </recipientlist>
> + </endpoint>
> + </send>
> + <drop/>
> + </in>
> +
> + <out>
> + <log level="full"/>
> + <!--Aggregate responses-->
> + <aggregate>
> + <onComplete xmlns:m0="http://services.samples"
> + expression="//m0:getQuoteResponse">
> + <send/>
> + </onComplete>
> + </aggregate>
> + </out>
> + </sequence>
> +
> + <sequence name="errorHandler">
> + <makefault response="true">
> + <code xmlns:tns="
> http://www.w3.org/2003/05/soap-envelope"
> value="tns:Receiver"/>
> + <reason value="COULDN'T SEND THE MESSAGE TO THE
> SERVER."/>
> + </makefault>
> + <send/>
> + </sequence>
> +</definitions>
> +</pre>
> +<p><strong>Objective: Demonstrate message routing to a set of
> +dynamic endpoints and aggregate responses</strong> </p>
> +
> +<p><strong>Prerequisites:</strong> </p>
> +
> +<p>Start ESB with sample configuration 63. (i.e. synapse -sample 63) </p>
> +
> +<p>Deploy the SimpleStockQuoteService and start three instances of sample
> Axis2 server as mentioned in sample 52.</p>
> +
> +<p>Above configuration routes a cloned copy of a message to each
> recipient defined within the dynamic recipient list.
> +Each recipient will respond back with a stock quote. When all the
> responses appear to synapse those resonses will be
> +aggregated to form the resultant response which will be sent back to the
> client.
> +<br/>To test this, invoke the client as follows: </p>
> +<pre xml:space="preserve">ant stockquote -Dtrpurl=http://localhost:8280/
> </pre>
> +
> +<p>If you sent your client request through a TCP based conversation
> monitoring tool such as TCPMon, you will notice the
> +structrue of the aggregated response message.</p>
> +
> +
> <h1><a name="MessageMediationQoS" id="MessageMediationQoS">Quality of
> Service addition or deduction samples in message mediation</a> </h1>
> <h2>
> <a name="Sample100" id="Sample100">Sample 100: Using WS-Security for
> outgoing messages</a></h2>
>
>
>
--
Hiranya Jayathilaka
Associate Technical Lead;
WSO2 Inc.; http://wso2.org
E-mail: hiranya@wso2.com; Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com