Skip to content

Commit

Permalink
Merge pull request #2229 from SanojPunchihewa/variable
Browse files Browse the repository at this point in the history
Copy variables to cloned messages and callback messages
  • Loading branch information
SanojPunchihewa authored Nov 6, 2024
2 parents 651cd57 + b3757b7 commit 3f7d461
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,12 @@ private void handleMessage(String messageID ,MessageContext response,
synapseInMessageContext.setProperty(
(String) key, synapseOutMsgCtx.getProperty((String) key));
}


for (Object key : synapseOutMsgCtx.getVariableKeySet()) {
synapseInMessageContext.setVariable(
(String) key, synapseOutMsgCtx.getVariable((String) key));
}

if(failOver){
//we may required to handle same message for failover cases only other than that
//should treat based on the incoming message
Expand Down Expand Up @@ -615,6 +620,11 @@ private void handleMessage(String messageID ,MessageContext response,
(String) key, synapseOutMsgCtx.getProperty((String) key));
}

for (Object key : synapseOutMsgCtx.getVariableKeySet()) {
synapseInMessageContext.setVariable(
(String) key, synapseOutMsgCtx.getVariable((String) key));
}

if (successfulEndpoint instanceof OAuthConfiguredHTTPEndpoint) {

OAuthConfiguredHTTPEndpoint httpEndpoint = (OAuthConfiguredHTTPEndpoint) successfulEndpoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,19 @@ public static MessageContext cloneMessageContext(MessageContext synCtx, boolean
}
}

// copy all the variables to the newCtx
for (Object o : synCtx.getVariableKeySet()) {
String strkey = (String) o;
Object obj = synCtx.getVariable(strkey);
if (obj instanceof OMElement) {
if (log.isDebugEnabled()) {
log.debug("Deep clone for OMElement");
}
obj = ((OMElement) obj).cloneOMElement();
}
newCtx.setVariable(strkey, obj);
}

// Make deep copy of fault stack so that parent will not be lost it's fault stack
Stack<FaultHandler> faultStack = synCtx.getFaultStack();
if (!faultStack.isEmpty()) {
Expand Down

0 comments on commit 3f7d461

Please sign in to comment.