Here is spring-integration-aws project. They provide example about Inbound Channle adapter:
@SpringBootApplication
public static class MyConfiguration {
@Autowired
private AmazonSQSAsync amazonSqs;
@Bean
public PollableChannel inputChannel() {
return new QueueChannel();
}
@Bean
public MessageProducer sqsMessageDrivenChannelAdapter() {
SqsMessageDrivenChannelAdapter adapter = new SqsMessageDrivenChannelAdapter(this.amazonSqs, "myQueue");
adapter.setOutputChannel(inputChannel());
return adapter;
}
}
Ok, Channel and SqsMessageDrivenChannelAdapter are defined, but what is the next? Let say that I have spring bean like that:
import com.amazonaws.services.sqs.model.Message;
@Component
public class MyComponent {
public void onMessage(Message message) throws Exception {
//handle sqs message
}
}
- How to
tellspring to pass all messages frommyQueueto this component? - Is there any additionbal configuration to process messages one by
one? For example after receiving message
SQSmark them as processing and they are not visible to other clients, so it is needed to fetch only one message, process nad fetch one next. Does this behavior enabled by default?