Extract more common parts
diff --git a/modules/core/src/main/java/org/apache/synapse/message/processors/forward/ForwardingJob.java b/modules/core/src/main/java/org/apache/synapse/message/processors/forward/ForwardingJob.java
index e8a1670..d487247 100644
--- a/modules/core/src/main/java/org/apache/synapse/message/processors/forward/ForwardingJob.java
+++ b/modules/core/src/main/java/org/apache/synapse/message/processors/forward/ForwardingJob.java
@@ -255,9 +255,7 @@
} else {
// This Means we have invoked an out only operation
// remove the message and reset the count
- messageStore.poll();
- processor.resetSentAttemptCount();
- sendResponseToReplySeq(outCtx);
+ doPostSuccessTasks(outCtx);
}
}
@@ -279,38 +277,48 @@
if (isHttpStatusCodeError(outCtx)) {
if (isRetryHttpStatusCode(outCtx)) {
doPostErrorTasks(inMsgCtx, outCtx);
+ } else {
+ doPostSuccessTasks(outCtx);
}
} else {
doPostErrorTasks(inMsgCtx, outCtx);
}
}
+ private void doPostSuccessTasks(MessageContext outCtx) {
+ messageStore.poll();
+ processor.resetSentAttemptCount();
+ sendResponseToReplySeq(outCtx);
+ }
+
private void doPostErrorTasks(MessageContext inMsgCtx, MessageContext outCtx) {
if (maxDeliverAttempts > 0) {
processor.incrementSendAttemptCount();
}
sendItToFaultSequence(outCtx);
if (maxDeliverAttempts > 0) {
- if (processor.getSendAttemptCount() >= maxDeliverAttempts) {
+ handleMaxDeliveryAttempts(inMsgCtx);
+ }
+ errorStop = true;
+ }
+
+ private void handleMaxDeliveryAttempts(MessageContext inMsgCtx) {
+ if (processor.getSendAttemptCount() >= maxDeliverAttempts) {
+ if (isMaxDeliverAttemptDropEnabled) {
+ //Since explicitly enabled the message drop after max delivery attempt
+ // message has been removed and reset the delivery attempt count of the processor
+ processor.resetSentAttemptCount();
+ messageStore.poll();
+ } else {
deactivate(processor, inMsgCtx);
}
}
- errorStop = true;
}
private boolean handleOutOnlyError(MessageContext inMsgCtx) {
if (maxDeliverAttempts > 0) {
processor.incrementSendAttemptCount();
- if (processor.getSendAttemptCount() >= maxDeliverAttempts) {
- if (isMaxDeliverAttemptDropEnabled) {
- //Since explicitly enabled the message drop after max delivery attempt
- // message has been removed and reset the delivery attempt count of the processor
- processor.resetSentAttemptCount();
- messageStore.poll();
- } else {
- deactivate(processor, inMsgCtx);
- }
- }
+ handleMaxDeliveryAttempts(inMsgCtx);
}
return true;
}