We need to see your code for this ExpressionEvaluatingRequestHandlerAdvice
, but any way, the AdviceMessage
is sent only in case of successful evaluation of the onSuccessExpression
:
if (evalResult != null && this.successChannel != null) {
AdviceMessage<?> resultMessage = new AdviceMessage<>(evalResult, message);
this.messagingTemplate.send(this.successChannel, resultMessage);
}
When you MessageHandler
fails (even if onSuccessExpression
fails), we go to this branch:
catch (RuntimeException e) {
Exception actualException = unwrapExceptionIfNecessary(e);
if (this.onFailureExpression != null) {
Object evalResult = evaluateFailureExpression(message, actualException);
if (this.returnFailureExpressionResult) {
return evalResult;
}
}
and there we send an ErrorMessage
:
if (evalResult != null && this.failureChannel != null) {
MessagingException messagingException =
new MessageHandlingExpressionEvaluatingAdviceException(message, "Handler Failed",
unwrapThrowableIfNecessary(exception), evalResult);
ErrorMessage errorMessage = new ErrorMessage(messagingException);
this.messagingTemplate.send(this.failureChannel, errorMessage);
}
So, what you show is really an expected behavior.
Therefore need to see you config and understand what is your expectation in both cases.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…