Enhancements requests In our framework, we use RocketMQ as the implementation for Spring Cloud Stream. We extend MessageProducerSupport to implement the core functionality.

In Spring 5 and Spring 6, after message sending fails a certain number of times, we use org.springframework.integration.handler.advice.ErrorMessageSendingRecoverer as the RecoveryCallback. Here's the relevant code:


if (this.retryTemplate != null) {
    this.retryTemplate.execute(context -> {
        this.sendMessage(message);
        return message;
    }, this.recoveryCallback);
}
else {
    this.sendMessage(message);
}

However, we've encountered an issue after upgrading to Spring 7. The RetryTemplate API in Spring 7 no longer supports RecoveryCallback. As a workaround, we considered implementing RetryListener#onRetryPolicyExhausted to manually invoke ErrorMessageSendingRecoverer#recover to achieve the same behavior.

Unfortunately, we found that ErrorMessageSendingRecoverer in Spring 7 is still based on RecoveryCallback. When calling the recover method, it requires an AttributeAccessor object. Although passing null seems to work based on the code, we don't believe this is a sustainable or forward-compatible approach. In spring-retry project, the AttributeAccessor was a RetryContext object, but this object no longer exists in Spring 7.

Questions:

  1. Are there any plans for the Spring team to optimize the ErrorMessageSendingRecoverer implementation?
  2. Now that Spring 7 has built-in retry support, should the legacy RecoveryCallback APIs be updated accordingly?
  3. Is there a recommended alternative approach in Spring 7 to achieve the same functionality in our framework?