Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Enable the endpoint to be configured for SQS #3479

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand All @@ -29,6 +32,7 @@
import com.netflix.conductor.sqs.eventqueue.SQSObservableQueue.Builder;

import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.sqs.AmazonSQS;
import com.amazonaws.services.sqs.AmazonSQSClientBuilder;
import rx.Scheduler;
Expand All @@ -38,10 +42,22 @@
@ConditionalOnProperty(name = "conductor.event-queues.sqs.enabled", havingValue = "true")
public class SQSEventQueueConfiguration {

@Autowired private SQSEventQueueProperties sqsProperties;

private static final Logger LOGGER = LoggerFactory.getLogger(SQSEventQueueConfiguration.class);

@ConditionalOnMissingBean
@Bean
public AmazonSQS getSQSClient(AWSCredentialsProvider credentialsProvider) {
return AmazonSQSClientBuilder.standard().withCredentials(credentialsProvider).build();
AmazonSQSClientBuilder builder =
AmazonSQSClientBuilder.standard().withCredentials(credentialsProvider);
if (!sqsProperties.getEndpoint().isEmpty()) {
LOGGER.info("Setting custom SQS endpoint to {}", sqsProperties.getEndpoint());
builder.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(
sqsProperties.getEndpoint(), System.getenv("AWS_REGION")));
}
return builder.build();
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public class SQSEventQueueProperties {
/** The AWS account Ids authorized to send messages to the queues */
private String authorizedAccounts = "";

/** The endpoint to use to connect to a local SQS server for testing */
private String endpoint = "";

public int getBatchSize() {
return batchSize;
}
Expand Down Expand Up @@ -76,4 +79,12 @@ public String getAuthorizedAccounts() {
public void setAuthorizedAccounts(String authorizedAccounts) {
this.authorizedAccounts = authorizedAccounts;
}

public String getEndpoint() {
return endpoint;
}

public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
}