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/11/20 16:44:43 UTC
svn commit: r345752 - in
/webservices/sandesha/trunk/src/org/apache/sandesha2:
AcknowledgementManager.java RMMsgContext.java workers/Sender.java
Author: chamikara
Date: Sun Nov 20 07:44:12 2005
New Revision: 345752
URL: http://svn.apache.org/viewcvs?rev=345752&view=rev
Log:
Ack piggybacking is working.
Acks get piggybacked to response messages if a message become available within the acknowledgement interval (otherwise acks are sent as standalone)
Added:
webservices/sandesha/trunk/src/org/apache/sandesha2/AcknowledgementManager.java
Modified:
webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java
webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java
Added: webservices/sandesha/trunk/src/org/apache/sandesha2/AcknowledgementManager.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/AcknowledgementManager.java?rev=345752&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/AcknowledgementManager.java (added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/AcknowledgementManager.java Sun Nov 20 07:44:12 2005
@@ -0,0 +1,86 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ */
+
+package org.apache.sandesha2;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.beanmanagers.RetransmitterBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.RetransmitterBean;
+import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+import org.apache.sandesha2.util.MsgInitializer;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.wsrm.IOMRMPart;
+import org.apache.sandesha2.wsrm.Sequence;
+import org.apache.sandesha2.wsrm.SequenceAcknowledgement;
+
+/**
+ * @author chamikara
+ *
+ */
+public class AcknowledgementManager {
+
+ public static void piggybackAckIfPresent (RMMsgContext applicationRMMsgContext) throws SandeshaException {
+ ConfigurationContext configurationContext = applicationRMMsgContext.getMessageContext().getSystemContext();
+ StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext);
+ RetransmitterBeanMgr retransmitterBeanMgr = storageManager.getRetransmitterBeanMgr();
+ SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropretyBeanMgr();
+
+ RetransmitterBean findBean = new RetransmitterBean ();
+
+ Sequence sequence = (Sequence) applicationRMMsgContext.getMessagePart(Constants.MessageParts.SEQUENCE);
+ if (sequence==null)
+ throw new SandeshaException ("Application message does not contain a sequence part");
+
+ String sequenceId = sequence.getIdentifier().getIdentifier();
+
+ SequencePropertyBean tempSequenceBean = sequencePropertyBeanMgr.retrieve(sequenceId,Constants.SequenceProperties.TEMP_SEQUENCE_ID);
+ if (tempSequenceBean==null)
+ throw new SandeshaException ("Temp Sequence is not set");
+
+ String tempSequenceId = (String) tempSequenceBean.getValue();
+ findBean.setTempSequenceId(tempSequenceId);
+ findBean.setMessagetype(Constants.MessageTypes.ACK);
+
+ Collection collection = retransmitterBeanMgr.find(findBean);
+ Iterator it = collection.iterator();
+
+ if (it.hasNext()) {
+ RetransmitterBean ackBean = (RetransmitterBean) it.next();
+
+ //deleting the ack entry.
+ retransmitterBeanMgr.delete(ackBean.getMessageId());
+
+ //Adding the ack to the application message
+ MessageContext ackMsgContext = SandeshaUtil.getStoredMessageContext(ackBean.getKey());
+ RMMsgContext ackRMMsgContext = MsgInitializer.initializeMessage(ackMsgContext);
+ if (ackRMMsgContext.getMessageType()!=Constants.MessageTypes.ACK)
+ throw new SandeshaException ("Invalid ack message entry");
+
+ SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) ackRMMsgContext.getMessagePart(Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
+ applicationRMMsgContext.setMessagePart(Constants.MessageParts.SEQ_ACKNOWLEDGEMENT,sequenceAcknowledgement);
+
+ applicationRMMsgContext.addSOAPEnvelope();
+ }
+
+ }
+}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java?rev=345752&r1=345751&r2=345752&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java Sun Nov 20 07:44:12 2005
@@ -29,6 +29,7 @@
import org.apache.axis2.context.AbstractContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPProcessingException;
import org.apache.sandesha2.util.SOAPAbstractFactory;
import org.apache.sandesha2.wsrm.IOMRMElement;
import org.apache.sandesha2.wsrm.IOMRMPart;
@@ -63,14 +64,18 @@
//MsgInitializer.populateRMMsgContext(ctx,this);
}
- public void addSOAPEnvelope() throws AxisFault {
+ public void addSOAPEnvelope() throws SandeshaException {
int SOAPVersion = Constants.SOAPVersion.v1_1;
if (!msgContext.isSOAP11())
SOAPVersion = Constants.SOAPVersion.v1_2;
if (msgContext.getEnvelope() == null) {
- msgContext.setEnvelope(SOAPAbstractFactory.getSOAPFactory(SOAPVersion).getDefaultEnvelope());
+ try {
+ msgContext.setEnvelope(SOAPAbstractFactory.getSOAPFactory(SOAPVersion).getDefaultEnvelope());
+ } catch (AxisFault e) {
+ throw new SandeshaException (e.getMessage());
+ }
}
SOAPEnvelope envelope = msgContext.getEnvelope();
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java?rev=345752&r1=345751&r2=345752&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java Sun Nov 20 07:44:12 2005
@@ -24,6 +24,7 @@
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.engine.AxisEngine;
import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.sandesha2.AcknowledgementManager;
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.SandeshaException;
@@ -89,6 +90,11 @@
.getMessageType())
+ "' message.");
}
+ }
+
+ if (rmMsgCtx.getMessageType()==Constants.MessageTypes.APPLICATION) {
+ //piggybacking if an ack if available for the same sequence.
+ AcknowledgementManager.piggybackAckIfPresent(rmMsgCtx);
}
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org