Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
类型EnableBinding已弃用,类型StreamListener已弃用-Spring Cloud Stream_Spring_Spring Cloud Stream - Fatal编程技术网

类型EnableBinding已弃用,类型StreamListener已弃用-Spring Cloud Stream

类型EnableBinding已弃用,类型StreamListener已弃用-Spring Cloud Stream,spring,spring-cloud-stream,Spring,Spring Cloud Stream,我正在使用SpringBootVersion2.4.2,并使用@InboundChannelAdapter进行SpringCloud流和Spring集成 import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.messaging.Source; import org.springframework.integration.annotation

我正在使用SpringBootVersion2.4.2,并使用
@InboundChannelAdapter
进行SpringCloud流和Spring集成

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

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);
    }
}
替代方案是什么?那么如何重构上述代码呢?随着节奏的加快,很多事情都在发生,很难理解会发生什么和会发生什么?

请参见

e、 在消费者方面

@Bean
消费者日志(){
返回str->{
系统输出打印项次(str);
};
}
绑定名称为
登录-0

在生产者方面,它是一个绑定名为sendTransactionDetails-out-0的
Supplier
bean