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 ml...@apache.org on 2006/11/28 10:44:50 UTC

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

Author: mlovett
Date: Tue Nov 28 01:44:49 2006
New Revision: 479964

URL: http://svn.apache.org/viewvc?view=rev&rev=479964
Log:
Use WS-A to track response messages instead of saving the message context. See SANDESHA2-51

Modified:
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/SequenceProcessor.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/TerminateManager.java

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java?view=diff&rev=479964&r1=479963&r2=479964
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java Tue Nov 28 01:44:49 2006
@@ -307,17 +307,24 @@
 
 		String REQUEST_SIDE_SEQUENCE_ID = "RequestSideSequenceID"; 		//used only at the server side
 		
+		// A pair of properties to keep track of the highest received message
+		// for an inbound sequence.
 		String HIGHEST_IN_MSG_NUMBER = "HighestInMsgNumber";
+		String HIGHEST_IN_MSG_ID = "HighestInMsgId";
 		
-		String HIGHEST_IN_MSG_KEY = "HighestInMsgKey";
+		// Once an inbound sequence is closed, or we receive a message with the
+		// 'LastMessage' marker, we record the message id of the highest message
+		// in the sequence.
+		String LAST_IN_MSG_ID = "LastInMessageId";
 		
+		// A pair pf properties to keep track of the highest transmitted message
+		// for an outbound sequence.
 		String HIGHEST_OUT_MSG_NUMBER = "HighestOutMsgNumber";
-		
-		String HIGHEST_OUT_MSG_KEY = "HighestOutMsgKey";
-		
+		String HIGHEST_OUT_RELATES_TO = "HighestOutRelatesTo";
+
+		// Once the last message for any outbound sequence has been acknowledged,
+		// we can safely close the sequence.
 		String LAST_OUT_MESSAGE_NO = "LastOutMessage";
-		
-		String LAST_IN_MESSAGE_NO = "LastInMessage";
 		
 		String SECURITY_TOKEN = "SecurityToken";
 		

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java?view=diff&rev=479964&r1=479963&r2=479964
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java Tue Nov 28 01:44:49 2006
@@ -140,8 +140,10 @@
                     RMMsgContext reqRMMsgCtx = MsgInitializer.initializeMessage(requestMsgCtx);
                     Sequence sequencePart = (Sequence) reqRMMsgCtx
                                     .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
-                    if (sequencePart != null)
-                            msgProcessor = new ApplicationMsgProcessor();// a rm intended message
+                    if (sequencePart != null) {
+            			String incomingSeqId = sequencePart.getIdentifier().getIdentifier();
+            			msgProcessor = new ApplicationMsgProcessor(incomingSeqId);// a rm intended message
+                    }
                 } else // if client side.
                     msgProcessor = new ApplicationMsgProcessor();
                 

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java?view=diff&rev=479964&r1=479963&r2=479964
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java Tue Nov 28 01:44:49 2006
@@ -120,7 +120,7 @@
 	public static final String outMsgHasNoEnvelope="outMsgHasNoEnvelope";
 	public static final String msgNumberExceededLastMsgNo="msgNumberExceededLastMsgNo";
 	public static final String ackInvalid="ackInvalid";
-	public static final String highestMsgKeyNotStored="highestMsgKeyNotStored";
+	public static final String highestMsgIdNotStored="highestMsgIdNotStored";
 	public static final String cannotHaveFinalWithNack="cannotHaveFinalWithNack";
 	public static final String accptButNoSequenceOffered="accptButNoSequenceOffered";
 	public static final String relatesToNotAvailable="relatesToNotAvailable";

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties?view=diff&rev=479964&r1=479963&r2=479964
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties Tue Nov 28 01:44:49 2006
@@ -145,7 +145,7 @@
 outMsgHasNoEnvelope=Out message does not have a envelope: {0}
 msgNumberExceededLastMsgNo=The received message number {0} on sequence {1} exceeds the message number {1} which was declared as last in a previosly received application message.
 ackInvalid=The SequenceAcknowledgement received is invalid as the lower value {1} is larger than upper value {2}.
-highestMsgKeyNotStored=Key of the highest message number has not been stored for sequence {0}
+highestMsgIdNotStored=The MessageId of the highest message number has not been stored for sequence {0}
 cannotHaveFinalWithNack=The ''Final'' element cannot be present when there are Nack elements under the SequenceAcknowledgement.
 accptButNoSequenceOffered=Error: An ''accept'' was received but there was no offered sequence entry.
 relatesToNotAvailable: Invalid create sequence message: ''RelatesTo'' part is not available.
@@ -202,7 +202,7 @@
 noAckRequestedElement=Message identified as of type ''AckRequested'' but it does not have an ''AckRequeted'' element.
 invalidAckMessageEntry=Invalid ack message entry: {0}
 seqPartIsNull=Sequence part is null.
-incomingSequenceNotValidID="The ID for the incoming sequence is not valid: {0}"
+incomingSequenceNotValidID=The ID for the incoming sequence is not valid: ''{0}''.
 
 seqFaultCannotBeExtractedToNonHeader=Cannot extract ''Sequence Fault'' part from a non-header element.
 seqElementCannotBeAddedToNonHeader=''Sequence'' element cannot be added to non-header element.

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java?view=diff&rev=479964&r1=479963&r2=479964
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java Tue Nov 28 01:44:49 2006
@@ -21,6 +21,7 @@
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.RelatesTo;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
@@ -67,6 +68,15 @@
 
 	private static final Log log = LogFactory.getLog(ApplicationMsgProcessor.class);
 
+	private String inboundSequence = null;
+	
+	public ApplicationMsgProcessor() {
+		// Nothing to do
+	}
+	
+	public ApplicationMsgProcessor(String inboundSequenceId) {
+		this.inboundSequence = inboundSequenceId;
+	}
 	
 	public boolean processInMessage(RMMsgContext rmMsgCtx) throws AxisFault {
 		if (log.isDebugEnabled()) {
@@ -75,7 +85,7 @@
 		}
 		return false;
 	}
-
+	
 	public boolean processOutMessage(RMMsgContext rmMsgCtx) throws AxisFault {
 		if (log.isDebugEnabled())
 			log.debug("Enter: ApplicationMsgProcessor::processOutMessage");
@@ -119,43 +129,22 @@
 
 		boolean lastMessage = false;
 		if (serverSide) {
-			// getting the request message and rmMessage.
-			MessageContext reqMsgCtx;
-			try {
-				reqMsgCtx = msgContext.getOperationContext().getMessageContext(
-						OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
-			} catch (AxisFault e) {
-				throw new SandeshaException(e);
-			}
-
-			RMMsgContext requestRMMsgCtx = MsgInitializer.initializeMessage(reqMsgCtx);
-
-			Sequence reqSequence = (Sequence) requestRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
-			if (reqSequence == null) {
-				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.seqPartIsNull);
+			if (inboundSequence == null || "".equals(inboundSequence)) {
+				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.incomingSequenceNotValidID, inboundSequence);
 				log.debug(message);
 				throw new SandeshaException(message);
 			}
 
-			String incomingSeqId = reqSequence.getIdentifier().getIdentifier();
-			if (incomingSeqId == null || "".equals(incomingSeqId)) {
-				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.incomingSequenceNotValidID, "''"
-						+ incomingSeqId + "''");
-				log.debug(message);
-				throw new SandeshaException(message);
-			}
-
-			long requestMsgNo = reqSequence.getMessageNumber().getMessageNumber();
-
-			internalSequenceId = SandeshaUtil.getOutgoingSideInternalSequenceID(incomingSeqId);
+			internalSequenceId = SandeshaUtil.getOutgoingSideInternalSequenceID(inboundSequence);
 
-			// deciding weather the last message.
-			String requestLastMsgNoStr = SandeshaUtil.getSequenceProperty(incomingSeqId,
-					Sandesha2Constants.SequenceProperties.LAST_IN_MESSAGE_NO, storageManager);
-			if (requestLastMsgNoStr != null) {
-				long requestLastMsgNo = Long.parseLong(requestLastMsgNoStr);
-				if (requestLastMsgNo == requestMsgNo)
-					lastMessage = true;
+			// Deciding weather this is the last message. We assume it is if it relates to
+			// a message which arrived with the LastMessage flag on it.
+			String lastRequestId = SandeshaUtil.getSequenceProperty(inboundSequence,
+					Sandesha2Constants.SequenceProperties.LAST_IN_MSG_ID, storageManager);
+			RelatesTo relatesTo = msgContext.getRelatesTo();
+			if(relatesTo != null && lastRequestId != null &&
+					lastRequestId.equals(relatesTo.getValue())) {
+				lastMessage = true;
 			}
 
 		} else {
@@ -239,16 +228,17 @@
 		SequencePropertyBean responseHighestMsgBean = new SequencePropertyBean(sequencePropertyKey,
 				Sandesha2Constants.SequenceProperties.HIGHEST_OUT_MSG_NUMBER, new Long(messageNumber).toString());
 		seqPropMgr.insert(responseHighestMsgBean);
+		RelatesTo relatesTo = msgContext.getRelatesTo();
+		if(relatesTo != null) {
+			SequencePropertyBean responseRelatesToBean = new SequencePropertyBean(sequencePropertyKey,
+					Sandesha2Constants.SequenceProperties.HIGHEST_OUT_RELATES_TO, relatesTo.getValue());
+			seqPropMgr.insert(responseRelatesToBean);
+		}
 
 		if (lastMessage) {
-
-			SequencePropertyBean responseHighestMsgKeyBean = new SequencePropertyBean(sequencePropertyKey,
-					Sandesha2Constants.SequenceProperties.HIGHEST_OUT_MSG_KEY, storageKey);
-
 			SequencePropertyBean responseLastMsgKeyBean = new SequencePropertyBean(sequencePropertyKey,
 					Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO, new Long(messageNumber).toString());
 
-			seqPropMgr.insert(responseHighestMsgKeyBean);
 			seqPropMgr.insert(responseLastMsgKeyBean);
 		}
 

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/SequenceProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/SequenceProcessor.java?view=diff&rev=479964&r1=479963&r2=479964
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/SequenceProcessor.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/SequenceProcessor.java Tue Nov 28 01:44:49 2006
@@ -175,10 +175,6 @@
 		// message number retrieved from this sequence.
 		String highetsInMsgNoStr = SandeshaUtil.getSequenceProperty(propertyKey,
 				Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_NUMBER, storageManager);
-		String highetsInMsgKey = SandeshaUtil.getSequenceProperty(propertyKey,
-				Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY, storageManager);
-		if (highetsInMsgKey == null)
-			highetsInMsgKey = SandeshaUtil.getUUID();
 
 		long highestInMsgNo = 0;
 		if (highetsInMsgNoStr != null) {
@@ -186,24 +182,17 @@
 		}
 
 		if (msgNo > highestInMsgNo) {
-			highestInMsgNo = msgNo;
-
-			String str = new Long(msgNo).toString();
 			SequencePropertyBean highestMsgNoBean = new SequencePropertyBean(propertyKey,
-					Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_NUMBER, str);
-			SequencePropertyBean highestMsgKeyBean = new SequencePropertyBean(propertyKey,
-					Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY, highetsInMsgKey);
-
-			// storing the new message as the highest in message.
-			storageManager.removeMessageContext(highetsInMsgKey);
-			storageManager.storeMessageContext(highetsInMsgKey, msgCtx);
+					Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_NUMBER, Long.toString(msgNo));
+			SequencePropertyBean highestMsgIdBean = new SequencePropertyBean(propertyKey,
+					Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_ID, msgCtx.getMessageID());
 
 			if (highetsInMsgNoStr != null) {
 				seqPropMgr.update(highestMsgNoBean);
-				seqPropMgr.update(highestMsgKeyBean);
+				seqPropMgr.update(highestMsgIdBean);
 			} else {
 				seqPropMgr.insert(highestMsgNoBean);
-				seqPropMgr.insert(highestMsgKeyBean);
+				seqPropMgr.insert(highestMsgIdBean);
 			}
 		}
 

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java?view=diff&rev=479964&r1=479963&r2=479964
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java Tue Nov 28 01:44:49 2006
@@ -188,14 +188,14 @@
 
 		String highestImMsgNumberStr = SandeshaUtil.getSequenceProperty(requestSidesequencePropertyKey,
 				Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_NUMBER, storageManager);
-		String highestImMsgKey = SandeshaUtil.getSequenceProperty(requestSidesequencePropertyKey,
-				Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY, storageManager);
+		String highestImMsgId = SandeshaUtil.getSequenceProperty(requestSidesequencePropertyKey,
+				Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_ID, storageManager);
 
 		long highestInMsgNo = 0;
 		if (highestImMsgNumberStr != null) {
-			if (highestImMsgKey == null)
+			if (highestImMsgId == null)
 				throw new SandeshaException(SandeshaMessageHelper.getMessage(
-						SandeshaMessageKeys.highestMsgKeyNotStored, sequenceId));
+						SandeshaMessageKeys.highestMsgIdNotStored, sequenceId));
 
 			highestInMsgNo = Long.parseLong(highestImMsgNumberStr);
 		}
@@ -213,44 +213,22 @@
 			if (highestInMsgNo == 0) {
 				addResponseSideTerminate = false;
 			} else {
-
-				// setting the last in message property
+				// Mark up the highest inbound message as if it had the last message flag on it.
+				// 
+				String inMsgId = highestImMsgId;
 				SequencePropertyBean lastInMsgBean = new SequencePropertyBean(requestSidesequencePropertyKey,
-						Sandesha2Constants.SequenceProperties.LAST_IN_MESSAGE_NO, highestImMsgNumberStr);
+						Sandesha2Constants.SequenceProperties.LAST_IN_MSG_ID, highestImMsgId);
 				seqPropMgr.insert(lastInMsgBean);
-
-				MessageContext highestInMsg = storageManager.retrieveMessageContext(highestImMsgKey, configCtx);
-
-				// TODO get the out message in a storage friendly manner.
-				MessageContext highestOutMessage = highestInMsg.getOperationContext().getMessageContext(
-						OperationContextFactory.MESSAGE_LABEL_FAULT_VALUE);
-
-				if (highestOutMessage == null || highestOutMessage.getEnvelope() == null)
-					highestOutMessage = highestInMsg.getOperationContext().getMessageContext(
-							OperationContextFactory.MESSAGE_LABEL_OUT_VALUE);
-
-				if (highestOutMessage != null) {
-					if (highestOutMessage.getEnvelope() == null)
-						throw new SandeshaException(SandeshaMessageHelper
-								.getMessage(SandeshaMessageKeys.outMsgHasNoEnvelope));
-
-					RMMsgContext highestOutRMMsg = MsgInitializer.initializeMessage(highestOutMessage);
-					Sequence seqPartOfOutMsg = (Sequence) highestOutRMMsg
-							.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
-
-					if (seqPartOfOutMsg != null) {
-
-						// response message of the last in message can be
-						// considered as the last out message.
-						highestOutMsgNo = seqPartOfOutMsg.getMessageNumber().getMessageNumber();
-						SequencePropertyBean highestOutMsgBean = new SequencePropertyBean(
-								responseSideSequencePropertyKey ,
-								Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO, new Long(highestOutMsgNo)
-										.toString());
-
-						seqPropMgr.insert(highestOutMsgBean);
-						addResponseSideTerminate = true;
-					}
+				
+				// If an outbound message has already gone out with that relatesTo, then we can terminate
+				// right away.
+				String highestOutRelatesTo = SandeshaUtil.getSequenceProperty(responseSideSequencePropertyKey,
+						Sandesha2Constants.SequenceProperties.HIGHEST_OUT_RELATES_TO, storageManager);
+				if(highestOutRelatesTo != null && highestOutRelatesTo.equals(inMsgId)) {
+					String highOutMessageNumberString = SandeshaUtil.getSequenceProperty(responseSideSequencePropertyKey,
+							Sandesha2Constants.SequenceProperties.HIGHEST_OUT_MSG_NUMBER, storageManager);
+					highestOutMsgNo = Long.parseLong(highOutMessageNumberString);
+					addResponseSideTerminate = true;
 				}
 			}
 

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/TerminateManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/TerminateManager.java?view=diff&rev=479964&r1=479963&r2=479964
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/TerminateManager.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/TerminateManager.java Tue Nov 28 01:44:49 2006
@@ -143,13 +143,6 @@
 	private static void completeTerminationOfReceivingSide(ConfigurationContext configContext, String sequencePropertyKey,String sequenceId,
 			StorageManager storageManager) throws SandeshaException {
 
-		// removing the HighestInMessage entry.
-		String highestInMessageKey = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
-				Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY, storageManager);
-		if (highestInMessageKey != null) {
-			storageManager.removeMessageContext(highestInMessageKey);
-		}
-
 		removeReceivingSideProperties(configContext, sequencePropertyKey, sequenceId, storageManager);
 		
 		// removing nextMsgMgr entries



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