你是對的;它目前不支持帶註釋的POJO方法。
你可以解決它與配置bean(自動裝配的消息處理程序,並設置異步標誌)...
@SpringBootApplication
public class So40962780Application {
public static void main(String[] args) {
SpringApplication.run(So40962780Application.class, args);
}
@InboundChannelAdapter(channel = "in", poller = @Poller(fixedRate = "5000"))
public String gen() {
return "foo";
}
@ServiceActivator(inputChannel = "in", outputChannel = "out")
public ListenableFuture<String> foo(String in) {
SettableListenableFuture<String> future = new SettableListenableFuture<>();
future.set(in.toUpperCase());
return future;
}
@ServiceActivator(inputChannel = "out")
public void syso(Object payload) {
System.out.println(payload);
}
@Bean
public AsyncConfigurer asyncConfigurer() {
return new AsyncConfigurer();
}
public static class AsyncConfigurer {
@Autowired
@Qualifier("so40962780Application.foo.serviceActivator.handler")
private AbstractReplyProducingMessageHandler fooHandler;
@PostConstruct
public void configureAsync() {
this.fooHandler.setAsync(true);
}
}
}
謝謝,很好的解決辦法,我也不會拿出它我自己。我」 m雖然好奇,但它爲什麼在註釋中不被支持,因爲它似乎是有意這樣做的。疏忽?或者一些意想不到的困難?初看起來,似乎很容易添加。 – rainerfrey
只是一個疏忽。工廠bean支持它,但不支持註釋。隨意打開JIRA問題。 –