You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ch...@apache.org on 2005/10/09 19:07:14 UTC

svn commit: r312476 - in /webservices/sandesha/trunk/src/org/apache/sandesha2: ./ handlers/ msgprocessors/ util/

Author: chamikara
Date: Sun Oct  9 10:06:05 2005
New Revision: 312476

URL: http://svn.apache.org/viewcvs?rev=312476&view=rev
Log:
Client side - create sequence message exchange is working

Modified:
    webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/Sender.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqResponseMsgProcessor.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java?rev=312476&r1=312475&r2=312476&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java Sun Oct  9 10:06:05 2005
@@ -148,7 +148,8 @@
 
 		String OUT_SEQUENCE_ID = "OutSequenceId";
 		
-		String INCOMING_SEQUENCE_ID = "IncomingSequenceId";
+		//FIXME - rema
+		//String INCOMING_SEQUENCE_ID = "IncomingSequenceId";
 		
 		String TEMP_SEQUENCE_ID = "TempSequenceId";
 
@@ -231,6 +232,8 @@
 	int INVOKER_SLEEP_TIME = 1000;
 
 	int SENDER_SLEEP_TIME = 1000;
+	
+	int CLIENT_SLEEP_TIME = 1000;
 
 	int TERMINATE_DELAY = 1000;
 	

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java?rev=312476&r1=312475&r2=312476&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java Sun Oct  9 10:06:05 2005
@@ -125,11 +125,35 @@
 
 		//TODO decide - where to send create seq. Acksto or replyTo
 		SequencePropertyBean replyToBean = seqPropMgr.retrieve(tempSequenceId, Constants.SequenceProperties.REPLY_TO_EPR);
-		EndpointReference replyToEPR = (EndpointReference) replyToBean.getValue();
-		if (replyToEPR==null)
-			throw new SandeshaException ("ReplyTo EPR is not set");
+		SequencePropertyBean toBean = seqPropMgr.retrieve(tempSequenceId,Constants.SequenceProperties.TO_EPR);
+
+		if (toBean==null || toBean.getValue()==null)
+			throw new SandeshaException ("To EPR is not set.");
+		
+		EndpointReference toEPR = (EndpointReference) toBean.getValue();
+		EndpointReference replyToEPR = null;
+		EndpointReference acksToEPR = null;
+		
+		//AcksTo value is replyto value (if set). Otherwise anonymous.
+		if (replyToBean==null || replyToBean.getValue()==null){
+			acksToEPR = new EndpointReference (Constants.WSA.NS_URI_ANONYMOUS);
+		}else { 
+			acksToEPR = (EndpointReference) replyToBean.getValue();
+		}
+		
+		if (replyToBean!=null && replyToBean.getValue()!=null)
+			replyToEPR = (EndpointReference) replyToBean.getValue();
+
+		createSeqRMMsg.setTo(toEPR);
+		
+		//ReplyTo will be set only if not null.
+		if(replyToEPR!=null) 
+			createSeqRMMsg.setReplyTo(replyToEPR);
+		
+		
+		//FIXME - Give user a seperate way to set acksTo (client side)
+		createSequencePart.setAcksTo(new AcksTo(new Address(acksToEPR)));
 		
-		createSequencePart.setAcksTo(new AcksTo(new Address(replyToEPR)));
 		createSeqRMMsg.setMessagePart(Constants.MessageParts.CREATE_SEQ,
 				createSequencePart);
 
@@ -140,15 +164,7 @@
 		}
 
 		createSeqRMMsg.setAction(Constants.WSRM.ACTION_CREATE_SEQ);
-		EndpointReference to = applicationRMMsg.getTo();
-		if (to == null || to.getAddress() == null || to.getAddress() == null
-				|| to.getAddress() == "")
-			throw new SandeshaException(
-					"To value of the Application Message is not set correctly");
-
-		createSeqRMMsg.setTo(to);
-
-		createSeqRMMsg.setReplyTo(replyToEPR);
+		
 		createSeqRMMsg.setMessageId(createSeqMsgId);
 
 		MessageContext createSeqMsg = createSeqRMMsg.getMessageContext();

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/Sender.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/Sender.java?rev=312476&r1=312475&r2=312476&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/Sender.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/Sender.java Sun Oct  9 10:06:05 2005
@@ -25,6 +25,8 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.clientapi.InOutMEPClient;
+import org.apache.axis2.clientapi.TwoWayTransportBasedSender;
 import org.apache.axis2.context.AbstractContext;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
@@ -78,7 +80,13 @@
 				try {
 					updateMessage(msgCtx);
 
-					new AxisEngine(context).send(msgCtx);
+					if (msgCtx.isServerSide())
+						new AxisEngine(context).send(msgCtx);
+					else {
+						//TwoWayTransportBasedSender sender = new TwoWayTransportBasedSender ();
+						TwoWayTransportBasedSender.send(msgCtx, msgCtx.getTransportIn());
+						//inOutMepClient.invokeBlocking(msgCtx.getOperationDescription(),msgCtx);
+					}
 
 				} catch (AxisFault e1) {
 					e1.printStackTrace();

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java?rev=312476&r1=312475&r2=312476&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java Sun Oct  9 10:06:05 2005
@@ -118,21 +118,33 @@
 
 		} else {
 			//set the temp sequence id for the client side.
+			EndpointReference toEPR = msgCtx.getTo();
+			if (toEPR == null || toEPR.getAddress() == null
+					|| "".equals(toEPR.getAddress()))
+				throw new AxisFault(
+						"TO End Point Reference is not set correctly. This is a must for the sandesha client side.");
+
+			tempSequenceId = toEPR.getAddress();
 		}
 
 		//check if the fist message
 
-		boolean firstApplicationMessage = false;
-		if (serverSide) {
-			SequencePropertyBean outSequenceBean = seqPropMgr.retrieve(
-					tempSequenceId,
-					Constants.SequenceProperties.OUT_SEQUENCE_ID);
-			if (outSequenceBean == null)
-				firstApplicationMessage = true;
+		long messageNumber = getNextMsgNo(context, tempSequenceId);
 
-		} else {
+		boolean firstApplicationMessage = false;
+		if (messageNumber == 1)
+			firstApplicationMessage = true;
 
-		}
+		//		if (serverSide) {
+		//			SequencePropertyBean outSequenceBean = seqPropMgr.retrieve(
+		//					tempSequenceId,
+		//					Constants.SequenceProperties.OUT_SEQUENCE_ID);
+		//			if (outSequenceBean == null)
+		//				firstApplicationMessage = true;
+		//
+		//		} else {
+		//			
+		//		}
 
 		//if fist message - setup the sequence for the client side
 		if (!serverSide && firstApplicationMessage) {
@@ -190,37 +202,38 @@
 
 				//valid response
 
-				//FIXME - do not copy application messages. Coz u loose
-				// properties etc.
-				RMMsgContext newRMMsgCtx = SandeshaUtil.deepCopy(rmMsgCtx);
-				MessageContext newMsgCtx = newRMMsgCtx.getMessageContext();
-
-				//setting contexts
-				newMsgCtx.setServiceGroupContext(msgCtx
-						.getServiceGroupContext());
-				newMsgCtx.setServiceGroupContextId(msgCtx
-						.getServiceGroupContextId());
-				newMsgCtx.setServiceContext(msgCtx.getServiceContext());
-				newMsgCtx.setServiceContextID(msgCtx.getServiceContextID());
-				OperationContext newOpContext = new OperationContext(newMsgCtx
-						.getOperationDescription());
-
-				//if server side add request message
-				if (msgCtx.isServerSide()) {
-					MessageContext reqMsgCtx = msgCtx.getOperationContext()
-							.getMessageContext(
-									WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-					newOpContext.addMessageContext(reqMsgCtx);
-				}
-
-				newOpContext.addMessageContext(newMsgCtx);
-				newMsgCtx.setOperationContext(newOpContext);
-
-				//processing the response
-				processResponseMessage(newRMMsgCtx, tempSequenceId);
-
 				if (serverSide) {
 
+					//FIXME - do not copy application messages. Coz u loose
+					// properties etc.
+					RMMsgContext newRMMsgCtx = SandeshaUtil.deepCopy(rmMsgCtx);
+					MessageContext newMsgCtx = newRMMsgCtx.getMessageContext();
+
+					//setting contexts
+					newMsgCtx.setServiceGroupContext(msgCtx
+							.getServiceGroupContext());
+					newMsgCtx.setServiceGroupContextId(msgCtx
+							.getServiceGroupContextId());
+					newMsgCtx.setServiceContext(msgCtx.getServiceContext());
+					newMsgCtx.setServiceContextID(msgCtx.getServiceContextID());
+					OperationContext newOpContext = new OperationContext(
+							newMsgCtx.getOperationDescription());
+
+					//if server side add request message
+					if (msgCtx.isServerSide()) {
+						MessageContext reqMsgCtx = msgCtx.getOperationContext()
+								.getMessageContext(
+										WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+						newOpContext.addMessageContext(reqMsgCtx);
+					}
+
+					newOpContext.addMessageContext(newMsgCtx);
+					newMsgCtx.setOperationContext(newOpContext);
+
+					//processing the response
+					processResponseMessage(newRMMsgCtx, tempSequenceId,
+							messageNumber);
+
 					MessageContext reqMsgCtx = msgCtx.getOperationContext()
 							.getMessageContext(
 									WSDLConstants.MESSAGE_LABEL_IN_VALUE);
@@ -237,11 +250,27 @@
 								"false");
 					msgCtx.setPausedTrue(getName());
 
-					SOAPEnvelope env123 = msgCtx.getEnvelope();
-
 				} else {
-					//client side wait
 
+					//client side wait
+					boolean letMessageGo = false;
+					while (!letMessageGo) {
+						SequencePropertyBean outSequenceBean = seqPropMgr.retrieve(tempSequenceId, Constants.SequenceProperties.OUT_SEQUENCE_ID);
+						if (outSequenceBean==null){
+							try {
+								Thread.sleep(Constants.CLIENT_SLEEP_TIME);
+							} catch (InterruptedException e1) {
+								System.out.println ("Client was interupted...");
+							}
+						}else {
+							letMessageGo = true;
+						}
+					}
+
+					//processing the response
+					processResponseMessage(rmMsgCtx, tempSequenceId,
+							messageNumber);
+					
 				}
 			}
 
@@ -288,7 +317,7 @@
 	}
 
 	private void processResponseMessage(RMMsgContext rmMsg,
-			String tempSequenceId) throws SandeshaException {
+			String tempSequenceId, long messageNumber) throws SandeshaException {
 
 		MessageContext msg = rmMsg.getMessageContext();
 
@@ -337,24 +366,12 @@
 		if (replyToEPR != null)
 			rmMsg.setReplyTo(replyToEPR);
 
-		//Retransmitter bean entry for the application message
-		RetransmitterBean appMsgEntry = new RetransmitterBean();
-		String key = SandeshaUtil
-				.storeMessageContext(rmMsg.getMessageContext());
-		appMsgEntry.setKey(key);
-		appMsgEntry.setLastSentTime(0);
-		appMsgEntry.setMessageId(rmMsg.getMessageId());
-
 		Sequence sequence = new Sequence();
 
-		long nextMsgNo = getNextMsgNo(rmMsg.getMessageContext()
-				.getSystemContext(), tempSequenceId);
 		MessageNumber msgNumber = new MessageNumber();
-		msgNumber.setMessageNumber(nextMsgNo);
+		msgNumber.setMessageNumber(messageNumber);
 		sequence.setMessageNumber(msgNumber);
 
-		appMsgEntry.setMessageNumber(nextMsgNo);
-
 		//setting last message
 		if (msg.isServerSide()) {
 			//server side
@@ -384,7 +401,7 @@
 				SequencePropertyBean lastOutMsgBean = new SequencePropertyBean(
 						tempSequenceId,
 						Constants.SequenceProperties.LAST_OUT_MESSAGE,
-						new Long(nextMsgNo));
+						new Long(messageNumber));
 				sequencePropertyMgr.insert(lastOutMsgBean);
 			}
 
@@ -403,12 +420,12 @@
 			Identifier identifier = new Identifier();
 			identifier.setIndentifer(Constants.TEMP_SEQUENCE_ID);
 			sequence.setIdentifier(identifier);
-			appMsgEntry.setSend(false);
+
 		} else {
 			Identifier identifier = new Identifier();
 			identifier.setIndentifer((String) outSequenceBean.getValue());
 			sequence.setIdentifier(identifier);
-			appMsgEntry.setSend(true);
+
 		}
 
 		rmMsg.setMessagePart(Constants.MessageParts.SEQUENCE, sequence);
@@ -418,8 +435,26 @@
 			throw new SandeshaException(e1.getMessage());
 		}
 
-		appMsgEntry.setTempSequenceId(tempSequenceId);
-		retransmitterMgr.insert(appMsgEntry);
+		//send the message through sender only in the server case.
+		//in the client case use the normal flow.
+		if (msg.isServerSide()) {
+			//Retransmitter bean entry for the application message
+			RetransmitterBean appMsgEntry = new RetransmitterBean();
+			String key = SandeshaUtil.storeMessageContext(rmMsg
+					.getMessageContext());
+			appMsgEntry.setKey(key);
+			appMsgEntry.setLastSentTime(0);
+			appMsgEntry.setMessageId(rmMsg.getMessageId());
+			appMsgEntry.setMessageNumber(messageNumber);
+			if (outSequenceBean == null || outSequenceBean.getValue() == null) {
+				appMsgEntry.setSend(false);
+			} else {
+				appMsgEntry.setSend(true);
+
+			}
+			appMsgEntry.setTempSequenceId(tempSequenceId);
+			retransmitterMgr.insert(appMsgEntry);
+		}
 	}
 
 	private long getNextMsgNo(ConfigurationContext context,

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java?rev=312476&r1=312475&r2=312476&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java Sun Oct  9 10:06:05 2005
@@ -73,25 +73,18 @@
 
 
 
-		String tempSequenceId = null;
+		SequencePropertyBean tempSequenceBean = seqPropMgr.retrieve(
+				outSequenceId,
+				Constants.SequenceProperties.TEMP_SEQUENCE_ID);
+		
+		if (tempSequenceBean == null
+				|| tempSequenceBean.getValue() == null)
+			throw new SandeshaException(
+					"TempSequenceId is not set correctly");
+
+		String tempSequenceId = (String) tempSequenceBean.getValue();
 		
-		if (rmMsgCtx.getMessageContext().isServerSide()){
-			//getting IncomingSequenceId for the outSequenceId
-			SequencePropertyBean incomingSequenceBean = seqPropMgr.retrieve(
-					outSequenceId,
-					Constants.SequenceProperties.INCOMING_SEQUENCE_ID);
-			if (incomingSequenceBean == null
-					|| incomingSequenceBean.getValue() == null)
-				throw new SandeshaException(
-						"Incoming Sequence id is not set correctly");
 
-			String incomingSequenceId = (String) incomingSequenceBean.getValue();
-			tempSequenceId = incomingSequenceId;
-		}else {
-			//find temp sequence id for the client side.
-			
-			//IN CREATE SEQ RES PROCESSOR SET SET OUT SEQ - TEMP SEQ ID MATCH.
-		}
 
 		RetransmitterBean input = new RetransmitterBean();
 		input.setTempSequenceId(tempSequenceId);

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqResponseMsgProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqResponseMsgProcessor.java?rev=312476&r1=312475&r2=312476&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqResponseMsgProcessor.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqResponseMsgProcessor.java Sun Oct  9 10:06:05 2005
@@ -73,9 +73,9 @@
 		if (createSeqBean == null)
 			throw new SandeshaException("Create Sequence entry is not found");
 
-		String incomingSequenceId = createSeqBean.getTempSequenceId();
-		if (incomingSequenceId == null || "".equals(incomingSequenceId))
-			throw new SandeshaException("Incoming sequence ID has is not set");
+		String tempSequenceId = createSeqBean.getTempSequenceId();
+		if (tempSequenceId == null || "".equals(tempSequenceId))
+			throw new SandeshaException("TempSequenceId has is not set");
 
 		//deleting the create sequence entry.
 		retransmitterMgr.delete(createSeqMsgId);
@@ -84,15 +84,15 @@
 		SequencePropertyBeanMgr sequencePropMgr = AbstractBeanMgrFactory
 				.getInstance(configCtx).getSequencePropretyBeanMgr();
 		SequencePropertyBean outSequenceBean = new SequencePropertyBean(
-			incomingSequenceId,
+				tempSequenceId,
 				Constants.SequenceProperties.OUT_SEQUENCE_ID, newOutSequenceId);
-		SequencePropertyBean incomingSequenceBean = new SequencePropertyBean (newOutSequenceId,
-				Constants.SequenceProperties.INCOMING_SEQUENCE_ID, incomingSequenceId);
+		SequencePropertyBean tempSequenceBean = new SequencePropertyBean (newOutSequenceId,
+				Constants.SequenceProperties.TEMP_SEQUENCE_ID, tempSequenceId);
 		sequencePropMgr.insert(outSequenceBean);
-		sequencePropMgr.insert(incomingSequenceBean);
+		sequencePropMgr.insert(tempSequenceBean);
 		
 		RetransmitterBean target = new RetransmitterBean();
-		target.setTempSequenceId(incomingSequenceId);
+		target.setTempSequenceId(tempSequenceId);
 
 		Iterator iterator = retransmitterMgr.find(target).iterator();
 		while (iterator.hasNext()) {

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java?rev=312476&r1=312475&r2=312476&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java Sun Oct  9 10:06:05 2005
@@ -219,8 +219,10 @@
 
 		try {
 
-			MessageContext newMessageContext = new MessageContext(configCtx,
-					transportIn, transportOut);
+			MessageContext newMessageContext = new MessageContext(configCtx);
+			newMessageContext.setTransportIn(transportIn);
+			newMessageContext.setTransportOut(transportOut);
+			
 			newMessageContext.setProperty(MessageContext.TRANSPORT_OUT, msgCtx
 					.getProperty(MessageContext.TRANSPORT_OUT));
 			newMessageContext.setProperty(HTTPConstants.HTTPOutTransportInfo,



---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org