I am new to Spring framework and Spring Integration. I'm starting using spring boot with AWS service. I tried to use Channel adaptor and Service activator to get the message from SQS queue and send to another service inside the application periodically using poller.
@configuration
public class AppConfig
{
@Bean
@InboundChannelAdapter( value = "inputChannel", poller = @Poller(fixedDelay = "1000"))
public Message inboundAdaptor ()
{
//get message from SQS queue
System.out.println("get message");
return message;
}
@Bean
@ServiceActivator(inputChannel = "inputChannel")
public String msgActivator( Message message)
{
//call another service and pass message body to that service
System.out.println("This is message body" + messageBody);
return messageBody;
}
I expected that by doing above, the actions inside InboundChannelAdaptor
will be called periodically due to poller and pass the message information to my service using ServiceActivator
automatically as long as I have message in the SQS queue
.
I tested them with System.out.println( )
to show what I've got. However, System.out.println( )
printed only once for each method. Does that mean poller just polled only once and stop or I cannot test the periodical call with System.out.println( )
?
Any suggestion on the right way to implement this workflow is appreciated.