Amazon SQS and Message Acknowledgement
Hello folks,
Trying to use Spring Integration with Amazon's SQS (well, actually a wrapper around SQS that gives us hooks to do encryption etc) and we're running into some troubles. The basic problem is that we need to be able to read a message off of SQS, do some processing on it, and once the message is processed, delete it from the queue. A bit of detail on the lifecyle of an SQS message is here - http://aws.amazon.com/sqs/#details.
Our first attempt at this involved using a Channel Adapter to read messages off of SQS and onto a message channel. The problem with this is that it doesn't give us any hook to delete the message once processing is successful. It means we need to delete it at the same time we read it off the queue, so if our processing step fails, we lose the message.
Read - process - ack is a pretty common pattern for messaging. JMS has a way to ack messages, as does the AMQP spec, so I'm guessing there's some way to do this baked into Spring Integration that I'm just failing to find.
Little help?
Thanks,
Mike
This may solve the problem: Nevado
I was just searching for a way to integrate Amazons SQS in Spring and I found this project:
http://nevado.skyscreamer.org/
Nevado JMS is a JMS driver for Amazon SQS.
- Leverage cloud services in Amazon using standard Spring/J2EE metaphors
- Avoid tight coupling to cloud-specific API's inside your code
- Rapidly prototype enterprise clients in the cloud. Then deploy them anywhere.
How you get started:
Code:
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>nevado-jms</artifactId>
<version>1.0.0</version>
</dependency>
Code:
<!-- Pick your AWS SDK. Typica is pretty fast. -->
<bean id="sqsConnectorFactory" class="org.skyscreamer.nevado.jms.connector.typica.TypicaSQSConnectorFactory" />
<!-- And this is an implementation of javax.jms.ConnectionFactory -->
<bean id="connectionFactory" class="org.skyscreamer.nevado.jms.NevadoConnectionFactory">
<property name="sqsConnectorFactory" ref="sqsConnectorFactory" />
<property name="awsAccessKey" value="${aws.accessKey}" /> <!-- Set this -->
<property name="awsSecretKey" value="${aws.secretKey}" /> <!-- And this -->
</bean>
And that's it ... maybe you should give it a try.