我是Spring Integration的新手。我们使用Spring Integration注解创建我们的应用程序。我已经配置了一个@InboundChannelAdapter,轮询器的固定延迟为5秒。但问题是,只要我在weblogic上启动我的应用程序,适配器就开始轮询并访问端点,而实际上没有任何消息。我们需要调用rest服务,然后触发此适配器。有没有办法实现这一点呢?
蒂娅!
发布于 2019-12-24 22:51:02
将autoStartup属性设置为false,并使用控制总线来启动/停止它。
@SpringBootApplication
@IntegrationComponentScan
public class So59469573Application {
public static void main(String[] args) {
SpringApplication.run(So59469573Application.class, args);
}
}
@Component
class Integration {
@Autowired
private ApplicationContext context;
@InboundChannelAdapter(channel = "channel", autoStartup = "false",
poller = @Poller(fixedDelay = "5000"))
public String foo() {
return "foo";
}
@ServiceActivator(inputChannel = "channel")
public void handle(String in) {
System.out.println(in);
}
@ServiceActivator(inputChannel = "controlChannel")
@Bean
public ExpressionControlBusFactoryBean controlBus() {
return new ExpressionControlBusFactoryBean();
}
}
@MessagingGateway(defaultRequestChannel = "controlChannel")
interface Control {
void send(String control);
}
@RestController
class Rest {
@Autowired
Control control;
@PostMapping("/foo/{command}")
public void trigger(@PathVariable String command) {
if ("start".equals(command)) {
control.send("@'integration.foo.inboundChannelAdapter'.start()");
}
}
}https://stackoverflow.com/questions/59469573
复制相似问题