private AmazonSQSAsyncClientBuilder createStandardAsyncClientBuilder(SQSQueue queue, AWSCredentialsProvider credentials) { ClientConfiguration clientConfiguration = this.getClientConfiguration(queue); AmazonSQSAsyncClientBuilder builder = AmazonSQSAsyncClientBuilder.standard() .withClientConfiguration(clientConfiguration) .withCredentials(credentials) .withExecutorFactory(this.SQSExecutorFactory); if (queue != null) { Regions region = queue.getRegion(); if (region != null) { builder.withRegion(region); } } return builder; }
@Bean public AmazonSQSAsync getSQSClient() { return AmazonSQSAsyncClientBuilder.standard() .withCredentials(new ProfileCredentialsProvider(CREDENTIALS_PROVIDER)) .withRegion(Regions.AP_SOUTHEAST_2) .build(); }
@Before public void setup() { mockSqs(null); EndpointConfiguration endpoint = new EndpointConfiguration(UNIT_STACK_URL + ":" + SQS_PORT, "eu-central-1"); AWSCredentials credentials = new BasicAWSCredentials("key", "secret"); AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); sqs = AmazonSQSAsyncClientBuilder.standard().withEndpointConfiguration(endpoint) .withCredentials(credentialsProvider).build(); }
@Override public AmazonSQS createSQSAsync(final SQSQueue queue) { AWSCredentialsProvider credentials = queue.hasCredentials() ? queue.lookupAwsCredentials() : DefaultAWSCredentialsProviderChain.getInstance(); AmazonSQSAsyncClientBuilder sqsAsyncBuilder = createStandardAsyncClientBuilder(queue, credentials); final QueueBufferConfig queueBufferConfig = this.getQueueBufferConfig(queue); final AmazonSQSBufferedAsyncClient sqsBufferedAsync = new AmazonSQSBufferedAsyncClient(sqsAsyncBuilder.build(), queueBufferConfig); return sqsBufferedAsync; }
@Override public AmazonSQS createSQSAsync(String accessKey, String secretKey) { AmazonSQSAsyncClientBuilder sqsAsyncBuilder = createStandardAsyncClientBuilder(null, new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey))); final QueueBufferConfig queueBufferConfig = this.getQueueBufferConfig(null); final AmazonSQSBufferedAsyncClient sqsBufferedAsync = new AmazonSQSBufferedAsyncClient(sqsAsyncBuilder.build(), queueBufferConfig); return sqsBufferedAsync; }
public AmazonSQS createSQSAsync(String accessKey, String secretKey, String region) {//TODO check region is Enum? AmazonSQSAsyncClientBuilder sqsAsyncBuilder = createStandardAsyncClientBuilder(null, new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey))); if (StringUtils.isNotBlank(region)) { sqsAsyncBuilder.withRegion(Regions.valueOf(region)); } final QueueBufferConfig queueBufferConfig = this.getQueueBufferConfig(null); final AmazonSQSBufferedAsyncClient sqsBufferedAsync = new AmazonSQSBufferedAsyncClient(sqsAsyncBuilder.build(), queueBufferConfig); return sqsBufferedAsync; }
@Memoized AmazonSQSAsync get() { AmazonSQSAsync result = AmazonSQSAsyncClientBuilder.standard() .withCredentials(credentialsProvider()) .withEndpointConfiguration(endpointConfiguration()).build(); provisioned = true; return result; }
private AmazonSQSAsync buildAsyncClient() { final AmazonSQSAsyncClientBuilder builder = AmazonSQSAsyncClientBuilder.standard(); builder.setRegion(conf.region.getLabel()); builder.setCredentials(credentials); builder.setClientConfiguration(clientConfiguration); return builder.build(); }