spring-cloud / spring-cloud-stream

Framework for building Event-Driven Microservices
http://cloud.spring.io/spring-cloud-stream
Apache License 2.0
1.01k stars 614 forks source link

[docs] @ServiceActivator mode has been outdated? and some conflicts are found in the documentation #3008

Closed chenbihao closed 1 month ago

chenbihao commented 1 month ago

Describe the issue

@ServiceActivator mode has been outdated? and some conflicts are found in the documentation

I found here producing-and-consuming-messages-#Handling Errors to use the instructions to use @serviceActivator to make an error handling

And did not see the relevant instructions in the overview-error-handling, have the@ServiceActivator mode have been removed?

To Reproduce

I use this way invalid:

@ServiceActivator(inputChannel = "request-coupon-topic.add-coupon-group.errors")
public void requestCouponFallback(ErrorMessage errorMessage) throws Exception {
    log.info("consumer error fallback: {}", errorMessage);
}
      bindings:
        addCoupon-out-0:
          destination: request-coupon-topic
          content-type: application/json
          binder: my-rabbit
        addCoupon-in-0:
          destination: request-coupon-topic
          content-type: application/json
          group: add-coupon-group
          binder: my-rabbit
          consumer:
            maxAttempts: 3
            backOffInitialInterval: 1000
            backOffMaxInterval: 5000
            backOffMultiplier: 2

But it worked:

@ServiceActivator(inputChannel = "errorChannel")

it worked too:

@Bean
    public Consumer<ErrorMessage> requestCouponErrorHandler() {
        return v -> {
            log.info("consumer error handler: {}", v);
        };
    }

Version of the framework

spring-cloud 2023.0.3

Expected behavior Screenshots

olegz commented 1 month ago

Annotation-based programming model have ben deprecated for about 5 years and gace been removed for about 2 years, so please read this - https://docs.spring.io/spring-cloud-stream/reference/spring-cloud-stream/producing-and-consuming-messages.html

olegz commented 1 month ago

You can also read more on error-handling here - https://docs.spring.io/spring-cloud-stream/reference/spring-cloud-stream/overview-error-handling.html#handle-error-messages

chenbihao commented 1 month ago

Annotation-based programming model have ben deprecated for about 5 years and gace been removed for about 2 years, so please read this - docs.spring.io/spring-cloud-stream/reference/spring-cloud-stream/producing-and-consuming-messages.html

then should the content in the last chapter of this page be removed ?

image

olegz commented 1 month ago

Not really, since @ServiceActivator is not at all related to Spring Cloud Stream. It's an artifact of Spring Integration framework which we do support since Spring Cloud Stream and binders ate build on top of Spring Integration. That said, functional programming model is recommended over the @ServiceActivator as it provides more features.

As for other annotations such as @StreamListener, @Input/Output, they are all gone.