2

I have the following bean:

@Bean
public MessageProducer sqsMessageAdapter() {
  SqsMessageDrivenChannelAdapter adapter = new SqsMessageDrivenChannelAdapter(this.amazonSqs, awsConfiguration.myQueue.get());
  adapter.setAutoStartup(true);
  adapter.setMaxNumberOfMessages(1);
  adapter.setSendTimeout(2000);
  adapter.setVisibilityTimeout(200);
  adapter.setWaitTimeOut(20);
  adapter.setOutputChannel(this.myOutput);
  return adapter;
}

MORE INFO: I am trying to find a way of stopping/starting the polling on command, i'm doing this using annotations without xml.

Currently I am using the SqsMessageDrivenChannelAdapter and calling the stop method, followed by the start when I want to restart the channel adapter. The problem I am having is that a timeout exception gets thrown in the stop method regardless of timeout settings. This happens on the future.get() call (line 197 of SimpleMessageListenerContainer) I think this is causing start not to work. Start does not throw any exceptions but the poller does not pick up any new messages

UPDATE:

The start and stop commands seem to be working correctly. The problem seems to be that I cannot set the property:

public void setQueueStopTimeout(long queueStopTimeout) {
    this.queueStopTimeout = queueStopTimeout;
}

This lives with SimpleMessageListenerContainer.java from SqsMessageDrivenChannelAdapter.java without this I am getting timeouts as the default is not long enough.

1 Answers1

0

Your question isn't clear. Please, consider be more specific in the future.

Anyway let me guess, that you mean start()/stop() operations of that SqsMessageDrivenChannelAdapter. Not sure that what is the problem to inject it in the desired place and call those methods.

@Autowired
@Qualifier("sqsMessageAdapter")
private Lifecycle sqsMessageAdapter;
Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • I've tried doing this, the `stop()` results in a `TimeoutException` and then stops. However when I call `start()` i get "SqsMessageDrivenChannelAdapter: started sqsMessageAdapter" but doesn't poll any of the new messages. – pfitzsimons Jun 13 '16 at 16:40
  • Not sure what is your problem, but my tests against `Spring Cloud AWS 1.1.0.RELEASE` work well. – Artem Bilan Jun 13 '16 at 18:33
  • I have edited the question to be more specific, Cheers. – pfitzsimons Jun 14 '16 at 09:39
  • I think you have just found an omission and raised issue properly: https://github.com/spring-projects/spring-integration-aws/issues/36. Thank you! But you should agree with me that it is fully different story. And we have agreed with you that `stop/start` work properly. – Artem Bilan Jun 14 '16 at 15:23
  • Yes, `stop/start` works as intended. I have marked the answer as correct. – pfitzsimons Jun 14 '16 at 15:28