"차단하지 않음"이라는 것이 확실하지 않습니다. 이것은 나를 위해 잘 작동합니다 ...
@SpringBootApplication
public class So46973604Application {
private final Logger LOGGER = LoggerFactory.getLogger(So46973604Application.class);
public static void main(String[] args) {
SpringApplication.run(So46973604Application.class, args).close();
}
@Bean
ApplicationRunner runner(Gate gate) {
return args -> {
for (int i = 0; i < 20; i++) {
gate.send("foo");
LOGGER.info("Sent " + i);
}
};
}
@Bean
QueueChannel channel() {
return new QueueChannel(10);
}
@ServiceActivator(inputChannel = "channel", poller = @Poller(fixedDelay = "0"))
public void handle(String in) throws InterruptedException {
Thread.sleep(1_000);
}
@MessagingGateway(defaultRequestChannel = "channel")
public interface Gate {
void send(String out);
}
}
처음 10 개가 즉시 전송되고 대기열 차단 대기로 인해 초당 1 개가 전송됩니다.
왜 호출자를 차단하려면 비동기 게이트웨이가 필요하다고 생각하십니까?