[英]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-0
的Supplier<String>
bean。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.