ws-sandesha-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chamik...@apache.org
Subject svn commit: r578652 - in /webservices/sandesha/branches/sandesha2/java/1_3/modules: core/src/main/java/org/apache/sandesha2/ core/src/main/java/org/apache/sandesha2/client/ core/src/main/java/org/apache/sandesha2/msgprocessors/ core/src/main/java/org/a...
Date Mon, 24 Sep 2007 04:40:05 GMT
Author: chamikara
Date: Sun Sep 23 21:40:02 2007
New Revision: 578652

URL: http://svn.apache.org/viewvc?rev=578652&view=rev
Log:
Did some corrections to the implementation of the Replay Model.

1. Added a boolean property to the SequenceBean to identify whether or not that particular
sequence is working on the Replay Model.
This gets set in the CreateSeqMsgProcessor.java.
2. This property was used in the ApplicationMsgProcessor.java to decide whether or not the
set the resent to true. In the Replay Model we should not be setting the reSend to true since
we cannot retransmit messages without a duplicate application message.
3. Changed the SenderWorker to not to delete messages when resend=true. This is not a business
of the senderWorker. 
4. Sender was corrected to check the resend property before assigning a SendereBean to a SenderWorker.

Also some corrections were done to the AckRequest processing logic.
 

Modified:
    webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java
    webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClient.java
    webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java
    webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
    webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
    webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSequenceBean.java
    webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/util/MsgInitializer.java
    webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/workers/Sender.java
    webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
    webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/SandeshaClientTest.java

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java?rev=578652&r1=578651&r2=578652&view=diff
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java
(original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java
Sun Sep 23 21:40:02 2007
@@ -309,6 +309,10 @@
 		}
 	}
 	
+	/**
+	 * Gives the RM version. 
+	 * @return	Can be either <Sandesha2Constants.SPEC_VERSIONS.v1_1> or <Sandesha2Constants.SPEC_VERSIONS.v1_0>
+	 */
 	public String getRMSpecVersion () {
 		if (rmSpecVersion==null) {
 			//this may hv been set in the Options object.

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClient.java?rev=578652&r1=578651&r2=578652&view=diff
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClient.java
(original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClient.java
Sun Sep 23 21:40:02 2007
@@ -861,7 +861,14 @@
 
 		try {
 			//to inform the sandesha2 out handler
-			serviceClient.fireAndForget (null);
+			serviceClient.sendReceiveNonBlocking (null,new AxisCallback () {
+
+				public void onComplete() {}
+				public void onError(Exception e) {}
+				public void onFault(MessageContext msgContext) {}
+				public void onMessage(MessageContext msgContext) {}
+						
+			});
 		} catch (AxisFault e) {
 			String message = SandeshaMessageHelper.getMessage(
 					SandeshaMessageKeys.cannotSendAckRequestException, e.toString());

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java?rev=578652&r1=578651&r2=578652&view=diff
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java
(original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java
Sun Sep 23 21:40:02 2007
@@ -36,6 +36,7 @@
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.util.MessageContextBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.sandesha2.RMMsgContext;
@@ -160,11 +161,19 @@
 		
 		//creating the ack message. If the ackRequest was a standalone this will be a out (response)
message 
 		MessageContext ackMsgCtx = null;
-//		if (piggybackedAckRequest)
+		
+		//checking whether this is an standalone ack message.
+		boolean standAloneAck = false;
+		String action = msgContext.getOptions().getAction();
+		if (action!=null && 
+				Sandesha2Constants.SPEC_2007_02.Actions.ACTION_ACK_REQUEST.equals(action))
+			standAloneAck = true;
+		
+		if (standAloneAck)
+			ackMsgCtx =MessageContextBuilder.createOutMessageContext (msgContext);
+		else
 			ackMsgCtx = SandeshaUtil.createNewRelatedMessageContext(rmMsgCtx, ackOperation);
-//		else
-//			ackMsgCtx =MessageContextBuilder.createOutMessageContext (msgContext);
-			
+		
 		//setting up the RMMsgContext
 		RMMsgContext ackRMMsgCtx = MsgInitializer.initializeMessage(ackMsgCtx);
 		ackRMMsgCtx.setRMNamespaceValue(rmMsgCtx.getRMNamespaceValue());
@@ -181,7 +190,9 @@
 			throw new SandeshaException(e3.getMessage());
 		}
 
-		ackMsgCtx.setTo(acksTo);
+		if (!standAloneAck)
+			ackMsgCtx.setTo(acksTo);
+		
 		ackMsgCtx.setReplyTo(msgContext.getTo());
 		RMMsgCreator.addAckMessage(ackRMMsgCtx, sequenceId, rmdBean);
 		

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java?rev=578652&r1=578651&r2=578652&view=diff
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
(original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
Sun Sep 23 21:40:02 2007
@@ -552,6 +552,11 @@
 			appMsgEntry.setSequenceID(outSequenceID);
 		}
 		
+		//If the sequence is in replay mode. We set the reSend to false. 
+		//In replay mode we cannot do retransmissions unless the request message get duplicated.
+		if (rmsBean.isReplayModel())
+			appMsgEntry.setReSend(false);
+		
 		EndpointReference to = rmMsg.getTo();
 		if (to!=null)
 			appMsgEntry.setToAddress(to.getAddress());

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java?rev=578652&r1=578651&r2=578652&view=diff
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
(original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
Sun Sep 23 21:40:02 2007
@@ -223,7 +223,12 @@
 					
 					// Set the SOAP Version for this sequence.
 					rMSBean.setSoapVersion(SandeshaUtil.getSOAPVersion(createSeqRMMsg.getSOAPEnvelope()));
-
+					
+					if (isReplayModel(createSeqRMMsg)) {
+						rMSBean.setReplayModel(true);
+						rmdBean.setReplayModel(true);
+					}
+					
 					storageManager.getRMSBeanMgr().insert(rMSBean);
 					
 					SandeshaUtil.startWorkersForSequence(context, rMSBean);
@@ -361,6 +366,35 @@
 		if (log.isDebugEnabled())
 			log.debug("Exit: CreateSeqMsgProcessor::processOutMessage " + Boolean.FALSE);
 		return false;
+	}
+	
+	/**
+	 * Checks weather the created sequence belong to the reply model. For this following conditions
has to be fulfilled.
+	 * 
+	 * 1. ReplyTo should be anonymous
+	 * 2. There must be an offer for the response sequence.
+	 * 3. RM Spec should be 1.0.
+	 * 
+	 * @param createSequenceMessage
+	 * @return
+	 * @throws SandeshaException
+	 */
+	private boolean isReplayModel (RMMsgContext createSequenceMessage) throws SandeshaException
{
+		boolean replayModel = false;
+		
+		CreateSequence createSequence = (CreateSequence) createSequenceMessage.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
+		SequenceOffer offer = createSequence.getSequenceOffer();
+		
+		EndpointReference replyTo = createSequenceMessage.getReplyTo();
+		
+		String rmSpecVersion = createSequenceMessage.getRMSpecVersion();
+		
+		if (offer!=null &&
+				replyTo!=null && replyTo.hasAnonymousAddress() &&
+				rmSpecVersion!=null && rmSpecVersion.equals(Sandesha2Constants.SPEC_VERSIONS.v1_0))
+			replayModel = true;
+		
+		return replayModel;
 	}
 	
 }

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSequenceBean.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSequenceBean.java?rev=578652&r1=578651&r2=578652&view=diff
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSequenceBean.java
(original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSequenceBean.java
Sun Sep 23 21:40:02 2007
@@ -65,6 +65,8 @@
 	private boolean pollingMode=false;
 	
 	private String serviceName = null;
+	
+	private boolean replayModel = false;
 
 	/**
 	 * Flags that are used to check if the primitive types on this bean
@@ -76,6 +78,7 @@
 	private static final int CLOSED_FLAG                 = 0x00000010;
 	private static final int TERMINATED_FLAG             = 0x00000100;
 	private static final int POLLING_MODE_FLAG           = 0x00001000;
+	private static final int REPLAY_MODEL_FLAG           = 0x00010000;
 
 	public RMSequenceBean() {
 
@@ -202,6 +205,22 @@
 		this.serviceName = serviceName;
 	}
 
+	/**
+	 * Tells whether or not this sequence belong to the replay Model. For a sequence to be in
the replay model,
+	 * 
+	 * 1. RM version should be1.0
+	 * 2. Outbound sequence should have been offered.
+	 * 3. ReplyTo of the inbound sequence should be anonymous.
+	 */
+	public boolean isReplayModel() {
+		return replayModel;
+	}
+
+	public void setReplayModel(boolean replayModel) {
+		this.replayModel = replayModel;
+	  	this.flags |= REPLAY_MODEL_FLAG;
+	}
+	
 	public int getFlags() {
 		return flags;
 	}
@@ -259,6 +278,9 @@
 			match = false;
 		
 		else if((bean.flags & POLLING_MODE_FLAG) != 0 && bean.isPollingMode() != this.isPollingMode())
+			match = false;
+		
+		else if((bean.flags & REPLAY_MODEL_FLAG) != 0 && bean.isReplayModel() != this.isReplayModel())
 			match = false;
 		
 		return match;

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/util/MsgInitializer.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/util/MsgInitializer.java?rev=578652&r1=578651&r2=578652&view=diff
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/util/MsgInitializer.java
(original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/util/MsgInitializer.java
Sun Sep 23 21:40:02 2007
@@ -82,7 +82,9 @@
 			addressingNamespace = AddressingConstants.Final.WSA_NAMESPACE;
 
 		RMElements elements = new RMElements(addressingNamespace);
-		elements.fromSOAPEnvelope(msgCtx.getEnvelope(), msgCtx.getWSAAction());
+		
+		if (msgCtx.getEnvelope()!=null)
+			elements.fromSOAPEnvelope(msgCtx.getEnvelope(), msgCtx.getWSAAction());
 
 		String rmNamespace = null;
 

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/workers/Sender.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/workers/Sender.java?rev=578652&r1=578651&r2=578652&view=diff
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/workers/Sender.java
(original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/workers/Sender.java
Sun Sep 23 21:40:02 2007
@@ -154,7 +154,16 @@
 			SenderBeanMgr mgr = storageManager.getSenderBeanMgr();
 			SenderBean senderBean = mgr.getNextMsgToSend(sequenceId);
 			
-			if (senderBean == null) {
+			
+			
+			if (senderBean == null ||
+					(!senderBean.isReSend() && senderBean.getSentCount()>0)) {
+				
+				//We will be not proceeding if
+				//senderBean is Null 
+				//OR
+				//Sender bean is not valid for re-sending.
+				
 				if (log.isDebugEnabled()) log.debug("Exit: Sender::internalRun, no message for this sequence");
 				
 				if(transaction != null && transaction.isActive()) {

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java?rev=578652&r1=578651&r2=578652&view=diff
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
(original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
Sun Sep 23 21:40:02 2007
@@ -194,6 +194,9 @@
 				return;
 			}
 			
+			//if the message belong to the Replay Model, it will be send out only if 
+			
+			
 			boolean continueSending = updateMessage(rmMsgCtx,senderBean,storageManager);
 			//save changes done @ updateMessage -> MessageRetransmissionAdjuster.adjustRetransmittion
 			storageManager.getSenderBeanMgr().update(senderBean);
@@ -322,12 +325,6 @@
 				if (senderBean.isReSend()) {
 					bean1.setTimeToSend(senderBean.getTimeToSend());
 					senderBeanMgr.update(bean1);
-				} else {
-					senderBeanMgr.delete(bean1.getMessageID());
-
-					// removing the message from the storage.
-					String messageStoredKey = bean1.getMessageContextRefKey();
-					storageManager.removeMessageContext(messageStoredKey);
 				}
 			}
 

Modified: webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/SandeshaClientTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/SandeshaClientTest.java?rev=578652&r1=578651&r2=578652&view=diff
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/SandeshaClientTest.java
(original)
+++ webservices/sandesha/branches/sandesha2/java/1_3/modules/tests/src/test/java/org/apache/sandesha2/SandeshaClientTest.java
Sun Sep 23 21:40:02 2007
@@ -31,6 +31,7 @@
 import org.apache.sandesha2.client.SandeshaClientConstants;
 import org.apache.sandesha2.client.SequenceReport;
 import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.Transaction;
 import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
 import org.apache.sandesha2.storage.beans.SenderBean;
 import org.apache.sandesha2.util.SandeshaUtil;
@@ -313,7 +314,7 @@
 	public void testAckRequest () throws Exception {
 		
 		String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
-		String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+		String transportTo = "http://127.0.0.1:" + 8070 + "/axis2/services/RMSampleService";
 		
 		String repoPath = "target" + File.separator + "repos" + File.separator + "client";
 		String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator
+ "client_axis2.xml";
@@ -371,6 +372,8 @@
 				// Get the SenderBeanManager
 				SenderBeanMgr senderManager = storageManager.getSenderBeanMgr();
 						
+				Transaction transaction = storageManager.getTransaction();
+				
 				// Check that there are no sender beans inside the SenderBeanMgr.
 				SenderBean senderBean = new SenderBean();
 				senderBean.setSequenceID(sequenceId);
@@ -379,10 +382,13 @@
 				
 				// Find any sender beans for the to address.
 				List beans = senderManager.find(senderBean);
-				assertTrue("SenderBeans found when the list should be empty", beans.isEmpty());
 				
-				SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+				//only the ackRequested bean will be present.
+				assertTrue("SenderBeans found when the list should be empty", (beans.size()==1));
 				
+				SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+		
+				transaction.commit();
 				assertNotNull(sequenceReport.getSequenceID());
 				assertFalse(sequenceReport.isSecureSequence());
 



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


Mime
View raw message