Reputation: 95
I am new to Spring Integration. We are creating our application using Spring Integration Annotations. I have configured an @InboundChannelAdapter with poller fixed delay of 5 seconds. But the problem is as soon as I start my application on weblogic, the adapter starts polling and hits endpoint with practically no message. We need to call a rest service and then trigger this adapter. Is there a way to implement the same?
TIA!
Upvotes: 0
Views: 1589
Reputation: 174484
Set the autoStartup
property to false
and use a control bus to start/stop it.
@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()");
}
}
}
Upvotes: 1