简体   繁体   English

不推荐使用 EnableBinding 类型,不推荐使用 StreamListener 类型 - Spring Cloud Stream

[英]The type EnableBinding is deprecated, The type StreamListener is deprecated - Spring Cloud Stream

I am using Spring Boot version 2.4.2 and doing Spring Cloud Stream and Spring Integration using @InboundChannelAdapter .我正在使用 Spring 引导版本 2.4.2 并使用@InboundChannelAdapter云 Stream 和 Z38008DD81C2F4AFDEEZCEAdapter 集成

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.annotation.InboundChannelAdapter;

@EnableBinding(value = Source.class)
public class TransactionPublisher {
    
    @InboundChannelAdapter(channel = Source.OUTPUT)
    public String sendTransactionDetails() {
        return "{name:\"T1\", amount: \"1000\", transactionFor : \"Purchase\"}";
    }
}

RabbitmqReceiverApplication.java RabbitmqReceiverApplication.java

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;

@EnableBinding(value = Sink.class)
@SpringBootApplication
public class RabbitmqReceiverApplication {

    public static void main(String[] args) {
        SpringApplication.run(RabbitmqReceiverApplication.class, args);
    }

    @StreamListener(Sink.INPUT)
    public void log(String message) {
        System.out.println(message);
    }
}

What could be the alternative?有什么替代方案? how to refactor the above code then?那么如何重构上面的代码呢? A lot of things are happening with the pace getting difficult to understand whats coming and whats going off?很多事情正在发生,节奏变得越来越难以理解即将发生的事情和发生的事情?

See the documentation .请参阅文档

eg On the consumer side...例如,在消费者方面...

@Bean
Consumer<String> log() {
    return str -> {
        System.out.println(str);
    };
}

The binding name is log-in-0 .绑定名称是log-in-0

On the producer side, it's a Supplier<String> bean with binding name sendTransactionDetails-out-0 .在生产者方面,它是一个具有绑定名称sendTransactionDetails-out-0Supplier<String> bean。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 EnableBinding 在 Spring Cloud Stream 3.x 中被弃用 - EnableBinding is deprecated in Spring Cloud Stream 3.x EnableBinding, Output, Input deprecated since version of 3.1 of Spring Cloud Stream - EnableBinding, Output, Input deprecated Since version of 3.1 of Spring Cloud Stream StreamBridge binding 代替 EnableBinding 和 Output 注解,自 Spring Cloud Stream 3.1 版本起弃用 - StreamBridge binding instead of EnableBinding and Output annotations which are deprecated since 3.1 version of Spring Cloud Stream Spring 6: Spring 云 Stream Kafka - 替代@EnableBinding - Spring 6: Spring Cloud Stream Kafka - Replacement for @EnableBinding 为什么不推荐使用 StreamListener - Why StreamListener is deprecated Spring 引导 2.4.0 类型 HandlerInterceptorAdapter 已弃用 - Spring boot 2.4.0 The type HandlerInterceptorAdapter is deprecated 不建议使用LocalSessionFactoryBean类型 - The type LocalSessionFactoryBean is deprecated 不推荐使用WebMvcConfigurerAdapter类型 - The type WebMvcConfigurerAdapter is deprecated @EnableBinding @deprecated 自 3.1 起支持函数式编程 model - @EnableBinding @deprecated as of 3.1 in favor of functional programming model Spring Cloud Stream @StreamListener 自定义映射Jackson2MesageConverter - Spring Cloud Stream @StreamListener Custom MappingJackson2MesageConverter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM