当前位置: 首页>>代码示例>>Java>>正文


Java AmazonSQSClientBuilder类代码示例

本文整理汇总了Java中com.amazonaws.services.sqs.AmazonSQSClientBuilder的典型用法代码示例。如果您正苦于以下问题:Java AmazonSQSClientBuilder类的具体用法?Java AmazonSQSClientBuilder怎么用?Java AmazonSQSClientBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AmazonSQSClientBuilder类属于com.amazonaws.services.sqs包,在下文中一共展示了AmazonSQSClientBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
/**
 *  Loads the test-specific Log4J configuration and resets the environment.
 */
public void setUp(String propertiesName)
throws Exception
{
    URL config = ClassLoader.getSystemResource(propertiesName);
    assertNotNull("missing configuration: " + propertiesName, config);

    LogManager.resetConfiguration();
    PropertyConfigurator.configure(config);

    localLogger = Logger.getLogger(getClass());

    runId = String.valueOf(System.currentTimeMillis());
    resourceName = "SNSAppenderIntegrationTest-" + runId;
    System.setProperty("SNSAppenderIntegrationTest.resourceName", resourceName);

    localSNSclient = AmazonSNSClientBuilder.defaultClient();
    localSQSclient = AmazonSQSClientBuilder.defaultClient();
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:22,代码来源:SNSAppenderIntegrationTest.java

示例2: getClient

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
/**
 * Returns a client instance for AWS SQS.
 * @return a client that talks to SQS
 */
public static AmazonSQS getClient() {
	if (sqsClient != null) {
		return sqsClient;
	}
	if (Config.IN_PRODUCTION) {
		sqsClient = AmazonSQSClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(
			new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY))).
				withRegion(Config.AWS_REGION).build();
	} else {
		sqsClient = AmazonSQSClientBuilder.standard().
				withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("x", "x"))).
				withEndpointConfiguration(new EndpointConfiguration(LOCAL_ENDPOINT, "")).build();
	}

	Para.addDestroyListener(new DestroyListener() {
		public void onDestroy() {
			sqsClient.shutdown();
		}
	});
	return sqsClient;
}
 
开发者ID:Erudika,项目名称:para,代码行数:26,代码来源:AWSQueueUtils.java

示例3: changeMessageVisibilityMultiple

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
public static void changeMessageVisibilityMultiple(
        String queue_url, int timeout)
{
    AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();

    List<ChangeMessageVisibilityBatchRequestEntry> entries =
        new ArrayList<ChangeMessageVisibilityBatchRequestEntry>();

    entries.add(new ChangeMessageVisibilityBatchRequestEntry(
                "unique_id_msg1",
                sqs.receiveMessage(queue_url)
                   .getMessages()
                   .get(0)
                   .getReceiptHandle())
            .withVisibilityTimeout(timeout));

    entries.add(new ChangeMessageVisibilityBatchRequestEntry(
                "unique_id_msg2",
                sqs.receiveMessage(queue_url)
                   .getMessages()
                   .get(0)
                   .getReceiptHandle())
            .withVisibilityTimeout(timeout + 200));

    sqs.changeMessageVisibilityBatch(queue_url, entries);
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:27,代码来源:VisibilityTimeout.java

示例4: CloudtrailSQSClient

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
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;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-aws,代码行数:13,代码来源:CloudtrailSQSClient.java

示例5: sqsConnectionFactory

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
@Bean
public SQSConnectionFactory sqsConnectionFactory() throws JMSException {

    return new SQSConnectionFactory(
            new ProviderConfiguration(),
            AmazonSQSClientBuilder.standard()
                    .withRegion(Regions.AP_SOUTHEAST_2)
                    .withCredentials(new ProfileCredentialsProvider(CREDENTIALS_PROVIDER))
    );
}
 
开发者ID:hafidsousa,项目名称:webcrawler,代码行数:11,代码来源:AppConfig.java

示例6: createSqsClient

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
public static AmazonSQS createSqsClient(AWSCredentials credentials, ClientConfiguration cc, Regions region) {
    return AmazonSQSClientBuilder //
            .standard() //
            .withCredentials(new AWSStaticCredentialsProvider(credentials)) //
            .withRegion(region) //
            .build();
}
 
开发者ID:davidmoten,项目名称:rxjava2-aws,代码行数:8,代码来源:AwsClients.java

示例7: initializeSqs

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
private AmazonSQS initializeSqs() {
    BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretyKey);
    AWSStaticCredentialsProvider provider = new AWSStaticCredentialsProvider(awsCredentials);

    return AmazonSQSClientBuilder.standard()
            .withCredentials(provider)
            .withRegion(Regions.US_EAST_2)
            .build();
}
 
开发者ID:hunterSThompson,项目名称:aws-ski-resort,代码行数:10,代码来源:QueueService.java

示例8: get

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
@Override
public AmazonSQS get(SqsModule.EndpointConfig config) {
    AmazonSQSClientBuilder builder = AmazonSQSClientBuilder.standard();
    builder.withCredentials(credentialsProvider);
    if (config.endpoint().isPresent()) {
        builder.withEndpointConfiguration(
            new AwsClientBuilder.EndpointConfiguration(config.getEndpoint(), config.getRegionName())
        );
    } else {
        builder.withRegion(Regions.fromName(config.getRegionName()));
    }
    return builder.build();
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:14,代码来源:DefaultAmazonSQSProvider.java

示例9: init

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
private void init() {
    AWSCredentials awsCredentials = new BasicAWSCredentials(configuration.getAccessKeyId(), configuration.getSecretAccessKey());
    AmazonSQS sqs = AmazonSQSClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
            .withRegion(Regions.fromName(configuration.getRegion())).build();
    this.sqsMessageHandler = new SqsMessageHandler(sqs);

}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:8,代码来源:SqsPlugin.java

示例10: changeMessageVisibilitySingle

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
public static void changeMessageVisibilitySingle(
        String queue_url, int timeout)
{
    AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();

    // Get the receipt handle for the first message in the queue.
    String receipt = sqs.receiveMessage(queue_url)
                        .getMessages()
                        .get(0)
                        .getReceiptHandle();

    sqs.changeMessageVisibility(queue_url, receipt, timeout);
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:14,代码来源:VisibilityTimeout.java

示例11: main

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
public static void main(String[] args)
{
    final String queue_name = "testQueue" + new Date().getTime();
    AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();

    // first, create a queue (unless it exists already)
    try {
        CreateQueueResult cq_result = sqs.createQueue(queue_name);
    } catch (AmazonSQSException e) {
        if (!e.getErrorCode().equals("QueueAlreadyExists")) {
            throw e;
        }
    }

    final String queue_url = sqs.getQueueUrl(queue_name).getQueueUrl();

    // Send some messages to the queue
    for (int i = 0; i < 20; i++) {
        sqs.sendMessage(queue_url, "This is message " + i);
    }

    // change visibility timeout (single)
    changeMessageVisibilitySingle(queue_url, 3600);

    // change visibility timeout (multiple)
    changeMessageVisibilityMultiple(queue_url, 2000);
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:28,代码来源:VisibilityTimeout.java

示例12: main

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
public static void main(String[] args)
{
    final AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();

    try {
        CreateQueueResult create_result = sqs.createQueue(QUEUE_NAME);
    } catch (AmazonSQSException e) {
        if (!e.getErrorCode().equals("QueueAlreadyExists")) {
            throw e;
        }
    }

    String queueUrl = sqs.getQueueUrl(QUEUE_NAME).getQueueUrl();

    SendMessageRequest send_msg_request = new SendMessageRequest()
            .withQueueUrl(queueUrl)
            .withMessageBody("hello world")
            .withDelaySeconds(5);
    sqs.sendMessage(send_msg_request);


    // Send multiple messages to the queue
    SendMessageBatchRequest send_batch_request = new SendMessageBatchRequest()
            .withQueueUrl(queueUrl)
            .withEntries(
                    new SendMessageBatchRequestEntry(
                            "msg_1", "Hello from message 1"),
                    new SendMessageBatchRequestEntry(
                            "msg_2", "Hello from message 2")
                            .withDelaySeconds(10));
    sqs.sendMessageBatch(send_batch_request);

    // receive messages from the queue
    List<Message> messages = sqs.receiveMessage(queueUrl).getMessages();

    // delete messages from the queue
    for (Message m : messages) {
        sqs.deleteMessage(queueUrl, m.getReceiptHandle());
    }
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:41,代码来源:SendReceiveMessages.java

示例13: buildSqsClient

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
private void buildSqsClient() {
    if (sqsClient == null) {
        sqsClient = AmazonSQSClientBuilder.standard()
                .withCredentials(config.getAwsCredentialsProvider())
                .withRegion(config.getSqsRegion())
                .build();
    }
}
 
开发者ID:aws,项目名称:aws-cloudtrail-processing-library,代码行数:9,代码来源:AWSCloudTrailProcessingExecutor.java

示例14: SQSConnectionFactory

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
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();
        }
    };
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:16,代码来源:SQSConnectionFactory.java

示例15: canCreateFactoryWithCustomBuilder

import com.amazonaws.services.sqs.AmazonSQSClientBuilder; //导入依赖的package包/类
@Test
public void canCreateFactoryWithCustomBuilder() throws JMSException {
    AmazonSQSClientBuilder clientBuilder = AmazonSQSClientBuilder.standard().withRegion(Regions.US_EAST_1);
    SQSConnectionFactory factory = new SQSConnectionFactory(new ProviderConfiguration(), clientBuilder);
    SQSConnection connection = factory.createConnection();
    connection.close();
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:8,代码来源:SQSConnectionFactoryTest.java


注:本文中的com.amazonaws.services.sqs.AmazonSQSClientBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。