amazon-sqs-java-messaging-lib icon indicating copy to clipboard operation
amazon-sqs-java-messaging-lib copied to clipboard

Unable to consume SQS messages

Open sjhameenakshi opened this issue 5 years ago • 0 comments

I have upgraded my spring boot api version from 2.0 to 2.2.0 and java version from 8 to 11 . Post above up-gradation I am unable to consume the SQS messages . Please find the pom snippet below :

org.springframework.boot spring-boot-starter-parent 2.2.2.RELEASE org.springframework.cloud spring-cloud-dependencies Hoxton.SR2 pom import org.springframework spring-jms com.amazonaws amazon-sqs-java-messaging-lib 1.0.8 com.amazonaws aws-java-sdk 1.11.749

and to consume the message I am doing the following , please find the below code snippet

JmsConfig: (SQS Configuration class)

@Configuration(proxyBeanMethods = false) @EnableJms public class JmsConfig {

org.apache.logging.log4j.Logger LOGGER = LogManager.getLogger("CONSOLE_JSON_APPENDER");

String concurrencyValue;

private SQSConnectionFactory sqsConnectionFactory;

@PostConstruct public void init() { LOGGER.info("Listening to the queue");

}

public JmsConfig() {

sqsConnectionFactory = new SQSConnectionFactory(new ProviderConfiguration(), AmazonSQSClientBuilder.standard().withCredentials(new DefaultAWSCredentialsProviderChain())); }

@Bean public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() { concurrencyValue = String.valueOf(1); DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); factory.setConnectionFactory(this.sqsConnectionFactory); factory.setConnectionFactory(sqsConnectionFactory); factory.setDestinationResolver(new DynamicDestinationResolver()); factory.setConcurrency(concurrencyValue); factory.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE); return factory; }

Message Consumer Class :

@JmsListener(destination = "${ingestQueue}", containerFactory="jmsListenerContainerFactory") public void processMessage(@Payload String message) { logLevel.logLevel(); System.out.println("Incomming Payload from SQS" + message);

Can someone help me what is the mistake I am doing here or what needs to be changed .

sjhameenakshi avatar Mar 24 '20 13:03 sjhameenakshi