Spring 集成 - @InboundChannelAdapter 轮询
Spring Integration - @InboundChannelAdapter polling
我是 Spring 集成的新手。我们正在使用 Spring 集成注释创建我们的应用程序。
我已经配置了一个 @InboundChannelAdapter,轮询器固定延迟为 5 秒。但问题是,一旦我在 weblogic 上启动我的应用程序,适配器就会开始轮询并在几乎没有任何消息的情况下命中端点。
我们需要调用一个休息服务,然后触发这个适配器。
有没有办法实现相同的?
TIA!
将 autoStartup
属性 设置为 false
并使用控制总线 start/stop 它。
@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()");
}
}
}
我是 Spring 集成的新手。我们正在使用 Spring 集成注释创建我们的应用程序。 我已经配置了一个 @InboundChannelAdapter,轮询器固定延迟为 5 秒。但问题是,一旦我在 weblogic 上启动我的应用程序,适配器就会开始轮询并在几乎没有任何消息的情况下命中端点。 我们需要调用一个休息服务,然后触发这个适配器。 有没有办法实现相同的?
TIA!
将 autoStartup
属性 设置为 false
并使用控制总线 start/stop 它。
@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()");
}
}
}