I have successfully configured via Java an Inbound Channel Adapter for AWS SQS using a direct channel. This project uses a combination of JDBC and RabbitMQ with SQS as the inbound flow for 3 separate queues. I need durable messages so I'm trying to figure out how to leverage RabbitMQ. I'm confused with how to reference the AMQP channel. How do I reference the AMQP message channel from the setOutPutChannel? My goal is to only remove the message out of SQS if message is successfully published to RabbitMQ durable queue.
@Bean
public MessageProducer getSQSChannel() {
SqsMessageDrivenChannelAdapter adapter = new SqsMessageDrivenChannelAdapter(this.amazonSqs, MY_SQS_QUEUE);
adapter.setOutputChannel(????);
return adapter;
}
@Bean
public AmqpChannelFactoryBean messageDriven(ConnectionFactory connectionFactory) {
AmqpChannelFactoryBean factoryBean = new AmqpChannelFactoryBean(true);
factoryBean.setConnectionFactory(connectionFactory);
factoryBean.setQueueName("bar");
factoryBean.setPubSub(false);
return factoryBean;
}
Use
adapter.setOutputChannelName("messageDriven");
and the channel created by the factory bean will be resolved from its name at runtime.
EDIT
Or , as Artem said...
MessageProducer getSQSChannel(MessageChannel messageDriven) {
...
}