Java Code Examples for com.amazonaws.services.sqs.AmazonSQSClientBuilder#build()
The following examples show how to use
com.amazonaws.services.sqs.AmazonSQSClientBuilder#build() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqsClient.java From kafka-connect-sqs with Apache License 2.0 | 6 votes |
public SqsClient(Map<String, ?> configs) { log.warn(".ctor:configs={}", configs); AWSCredentialsProvider provider = null; try { provider = getCredentialsProvider(configs); } catch ( Exception e ) { log.error("Problem initializing provider", e); } final AmazonSQSClientBuilder builder = AmazonSQSClientBuilder.standard(); builder.setCredentials(provider); // // If there's an AWS credentials profile and/or region configured in the // // environment we will use it. // final String profile = System.getenv(AWS_PROFILE); // final String region = System.getenv(AWS_REGION); // if (Facility.isNotNullNorEmpty(profile)) { // builder.setCredentials(provider); // } // if (Facility.isNotNullNorEmpty(region)) { // builder.setRegion(region); // } // log.info("AmazonSQS using profile={}, region={}", profile, region); client = builder.build(); }
Example 2
Source File: AWSClientUtils.java From camel-kafka-connector with Apache License 2.0 | 5 votes |
public static AmazonSQS newSQSClient() { LOG.debug("Creating a custom SQS client for running a AWS SNS test"); AmazonSQSClientBuilder clientBuilder = AmazonSQSClientBuilder .standard(); String awsInstanceType = System.getProperty("aws-service.instance.type"); String region = getRegion(); if (awsInstanceType == null || awsInstanceType.equals("local-aws-container")) { String amazonHost = System.getProperty(AWSConfigs.AMAZON_AWS_HOST); ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.setProtocol(Protocol.HTTP); clientBuilder .withClientConfiguration(clientConfiguration) .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(amazonHost, region)) .withCredentials(new TestAWSCredentialsProvider("accesskey", "secretkey")); } else { clientBuilder .withRegion(region) .withCredentials(new TestAWSCredentialsProvider()); } return clientBuilder.build(); }
Example 3
Source File: AWSSQSMetaDataExtension.java From syndesis with Apache License 2.0 | 5 votes |
@Override public Optional<MetaData> meta(Map<String, Object> parameters) { final String accessKey = ConnectorOptions.extractOption(parameters, "accessKey"); final String secretKey = ConnectorOptions.extractOption(parameters, "secretKey"); final String region = ConnectorOptions.extractOption(parameters, "region"); AmazonSQSClientBuilder clientBuilder; AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); clientBuilder = AmazonSQSClientBuilder.standard().withCredentials(credentialsProvider); clientBuilder = clientBuilder.withRegion(Regions.valueOf(region)); AmazonSQS sqsClient = clientBuilder.build(); List<String> attributeNames = new ArrayList<String>(); attributeNames.add("All"); try { ListQueuesResult result = sqsClient.listQueues(); Set<String> setQueue = new HashSet<String>(); if (result.getQueueUrls() != null) { for (String entry : result.getQueueUrls()) { GetQueueAttributesRequest req = new GetQueueAttributesRequest(); req.setQueueUrl(entry); req.setAttributeNames(attributeNames); GetQueueAttributesResult c = sqsClient.getQueueAttributes(req); setQueue.add(c.getAttributes().get(QueueAttributeName.QueueArn.name())); } } return Optional.of(MetaDataBuilder.on(getCamelContext()).withAttribute(MetaData.CONTENT_TYPE, "text/plain").withAttribute(MetaData.JAVA_TYPE, String.class) .withPayload(setQueue).build()); } catch (Exception e) { throw new IllegalStateException("Get information about existing queues with has failed.", e); } }
Example 4
Source File: CloudtrailSQSClient.java From graylog-plugin-aws with Apache License 2.0 | 5 votes |
public CloudtrailSQSClient(Region region, String queueName, AWSAuthProvider authProvider, HttpUrl proxyUrl, ObjectMapper objectMapper) { AmazonSQSClientBuilder clientBuilder = AmazonSQSClientBuilder.standard().withRegion(region.getName()).withCredentials(authProvider); if (proxyUrl != null) { clientBuilder.withClientConfiguration(Proxy.forAWS(proxyUrl)); } this.sqs = clientBuilder.build(); this.queueName = queueName; this.objectMapper = objectMapper; }
Example 5
Source File: SQSConnectionFactory.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
public SQSConnectionFactory(ProviderConfiguration providerConfiguration, final AmazonSQSClientBuilder clientBuilder) { if (providerConfiguration == null) { throw new IllegalArgumentException("Provider configuration cannot be null"); } if (clientBuilder == null) { throw new IllegalArgumentException("AmazonSQS client builder cannot be null"); } this.providerConfiguration = providerConfiguration; this.amazonSQSClientSupplier = new AmazonSQSClientSupplier() { @Override public AmazonSQS get() { return clientBuilder.build(); } }; }