Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Grails Amazon SQS Example JMS configuration
import com.amazonaws.auth.AWSCredentials
import com.amazonaws.auth.AWSStaticCredentialsProvider
import com.amazonaws.regions.Regions
import grails.util.Holders
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.jms.annotation.EnableJms
import org.springframework.jms.config.DefaultJmsListenerContainerFactory
import org.springframework.jms.core.JmsTemplate
* Created by Evgeny Smirnov <>
class JmsConfig {
* SQSConnectionFactory class implements the ConnectionFactory interface as defined by the JMS standard,
* allowing it to be used with standard JMS interfaces and classes to connect to SQS
* */
SQSConnectionFactory connectionFactory =
new SQSConnectionFactory(
new ProviderConfiguration(),
.withCredentials(new AWSStaticCredentialsProvider(
getAWSAccessKeyId: { },
getAWSSecretKey : { }
] as AWSCredentials))
//Will be used to create listeners
DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
new DefaultJmsListenerContainerFactory(
connectionFactory: this.connectionFactory
//Will be used to send messages
JmsTemplate defaultJmsTemplate() {
new JmsTemplate(this.connectionFactory)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.