You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sandesha-dev@ws.apache.org by ja...@apache.org on 2006/07/14 18:16:43 UTC
svn commit: r421935 - in /webservices/sandesha/branches/sandesha_1_0:
samples/org/apache/sandesha/samples/MultiThreadedEcho.java
src/org/apache/sandesha/SandeshaContext.java
Author: jaliya
Date: Fri Jul 14 09:16:42 2006
New Revision: 421935
URL: http://svn.apache.org/viewvc?rev=421935&view=rev
Log:
New sample for multiple threads in the client side. Fixed a minor problem in SandeshaContext
Added:
webservices/sandesha/branches/sandesha_1_0/samples/org/apache/sandesha/samples/MultiThreadedEcho.java
Modified:
webservices/sandesha/branches/sandesha_1_0/src/org/apache/sandesha/SandeshaContext.java
Added: webservices/sandesha/branches/sandesha_1_0/samples/org/apache/sandesha/samples/MultiThreadedEcho.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha_1_0/samples/org/apache/sandesha/samples/MultiThreadedEcho.java?rev=421935&view=auto
==============================================================================
--- webservices/sandesha/branches/sandesha_1_0/samples/org/apache/sandesha/samples/MultiThreadedEcho.java (added)
+++ webservices/sandesha/branches/sandesha_1_0/samples/org/apache/sandesha/samples/MultiThreadedEcho.java Fri Jul 14 09:16:42 2006
@@ -0,0 +1,85 @@
+package org.apache.sandesha.samples;
+
+import org.apache.axis.components.uuid.UUIDGen;
+import org.apache.axis.components.uuid.UUIDGenFactory;
+import org.apache.axis.client.Service;
+import org.apache.axis.client.Call;
+import org.apache.axis.encoding.XMLType;
+import org.apache.axis.AxisFault;
+import org.apache.sandesha.SandeshaContext;
+import org.apache.sandesha.Constants;
+import org.apache.sandesha.RMReport;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.ParameterMode;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Jaliya
+ * Date: Jul 14, 2006
+ * Time: 11:22:05 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class MultiThreadedEcho extends Thread {
+ private static String defaultServerPort = "8070";
+ private static String defaultClientPort = "9070";
+ private static String targetURL = "http://127.0.0.1:" + defaultServerPort +
+ "/axis/services/RMSampleService";
+
+ static UUIDGen uuidGen = UUIDGenFactory.getUUIDGen();
+
+ public static void main(String[] args) {
+ for (int i = 0; i < 10; i++) {
+ MultiThreadedEcho th = new MultiThreadedEcho();
+ th.start();
+ }
+ }
+
+ public void run() {
+ System.out.println("EchoClientAsyncAck Started ........");
+ try {
+
+ SandeshaContext ctx = new SandeshaContext();
+
+ String str = uuidGen.nextUUID();
+
+ Service service = new Service();
+ Call call = (Call) service.createCall();
+
+
+ ctx.setAcksToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.setReplyToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.setSendOffer(true);
+ ctx.initCall(call, targetURL, "urn:wsrm:echoString", Constants.ClientProperties.IN_OUT);
+
+ call.setOperationName(new QName("http://tempuri.org/", "echoString"));
+
+ call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
+ call.addParameter("arg2", XMLType.XSD_STRING, ParameterMode.IN);
+ call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
+
+ String ret = (String) call.invoke(new Object[]{"Sandesha Echo 1", str});
+ System.out.println("The Response for First Messsage is :" + ret);
+
+ ret = (String) call.invoke(new Object[]{"Sandesha Echo 2", str});
+ System.out.println("The Response for Second Messsage is :" + ret);
+
+ ctx.setLastMessage(call);
+ ret = (String) call.invoke(new Object[]{"Sandesha Echo 3", str});
+ System.out.println("The Response for Third Messsage is :" + ret);
+
+ RMReport report = ctx.endSequence();
+
+
+ if (report != null) {
+ System.out.println("\n***********Printing RM Report***********");
+ System.out.println("Is all messages acked - " + report.isAllAcked());
+ System.out.println("No of response messages - " + report.getNumberOfReturnMessages());
+ System.out.println("****************************************\n");
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Modified: webservices/sandesha/branches/sandesha_1_0/src/org/apache/sandesha/SandeshaContext.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha_1_0/src/org/apache/sandesha/SandeshaContext.java?rev=421935&r1=421934&r2=421935&view=diff
==============================================================================
--- webservices/sandesha/branches/sandesha_1_0/src/org/apache/sandesha/SandeshaContext.java (original)
+++ webservices/sandesha/branches/sandesha_1_0/src/org/apache/sandesha/SandeshaContext.java Fri Jul 14 09:16:42 2006
@@ -21,6 +21,8 @@
import org.apache.axis.SimpleChain;
import org.apache.axis.client.Call;
import org.apache.axis.components.logger.LogFactory;
+import org.apache.axis.components.uuid.UUIDGen;
+import org.apache.axis.components.uuid.UUIDGenFactory;
import org.apache.commons.logging.Log;
import org.apache.sandesha.client.ClientHandlerUtil;
import org.apache.sandesha.client.ClientListener;
@@ -60,7 +62,9 @@
private static HashMap seqMap = new HashMap();
private HashMap callMap = new HashMap();
- private long key;
+ private static UUIDGen uuidGen=UUIDGenFactory.getUUIDGen();
+ private String key;
+
private String toURL;
private String sourceURL;
@@ -157,21 +161,21 @@
private void initSandeshaAsync() throws AxisFault {
messageNumber = 0;
- key = System.currentTimeMillis();
+ key = uuidGen.nextUUID();
SandeshaContext.insideServer = false;
init(true);
startListener();
- seqMap.put(new Long(key), this);
+ seqMap.put(key, this);
report = new RMReport();
}
public SandeshaContext(int sync) throws AxisFault {
this.sync = true;
messageNumber = 0;
- key = System.currentTimeMillis();
+ key = uuidGen.nextUUID();
SandeshaContext.insideServer = false;
init(true);
- seqMap.put(new Long(key), this);
+ seqMap.put(key, this);
report = new RMReport();
}
@@ -185,20 +189,20 @@
public SandeshaContext(boolean insideServer) throws AxisFault {
messageNumber = 0;
- key = System.currentTimeMillis();
+ key = uuidGen.nextUUID();
SandeshaContext.insideServer = insideServer;
init(true);
- seqMap.put(new Long(key), this);
+ seqMap.put(key, this);
report = new RMReport();
}
public SandeshaContext(boolean insideServer, int sync) throws AxisFault {
this.sync = true;
messageNumber = 0;
- key = System.currentTimeMillis();
+ key = uuidGen.nextUUID();
SandeshaContext.insideServer = insideServer;
init(true);
- seqMap.put(new Long(key), this);
+ seqMap.put(key, this);
report = new RMReport();
}
@@ -356,7 +360,7 @@
this.report.setAllAcked(true);
}
- seqMap.remove(new Long(key));
+ seqMap.remove(key);
if (seqMap.isEmpty()) {
if (listenerStarted) {
clientListner.stop();
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org