Skip to content

Commit

Permalink
Merge pull request #2105 from GDLMadushanka/iteratePerformance
Browse files Browse the repository at this point in the history
Avoid cloning the message envelope when iterating
  • Loading branch information
GDLMadushanka authored Nov 3, 2023
2 parents 2806d2f + 56fde8d commit 5b88561
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.jayway.jsonpath.JsonPath;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.context.OperationContext;
Expand Down Expand Up @@ -372,10 +375,17 @@ private MessageContext getIteratedMessage(MessageContext synCtx, int msgNumber,
throws AxisFault, JaxenException {

// clone the message for the mediation in iteration
MessageContext newCtx = MessageHelper.cloneMessageContext(synCtx);

//Remove the original jsonstream from the context
JsonUtil.removeJsonPayload(((Axis2MessageContext) newCtx).getAxis2MessageContext());
MessageContext newCtx = MessageHelper.cloneMessageContext(synCtx, false, false);
// Adding an empty envelope since JsonUtil.getNewJsonPayload requires an envelope
SOAPFactory fac;
if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI
.equals(synCtx.getEnvelope().getBody().getNamespace().getNamespaceURI())) {
fac = OMAbstractFactory.getSOAP11Factory();
} else {
fac = OMAbstractFactory.getSOAP12Factory();
}
SOAPEnvelope newEnvelope = fac.getDefaultEnvelope();
newCtx.setEnvelope(newEnvelope);

if (id != null) {
// set the parent correlation details to the cloned MC -
Expand Down

0 comments on commit 5b88561

Please sign in to comment.