Search in sources :

Example 1 with ProviderConfiguration

use of com.amazon.sqs.javamessaging.ProviderConfiguration in project goobi-workflow by intranda.

the class ExternalConnectionFactory method createSQSConnection.

private static Connection createSQSConnection(String username, String password) throws JMSException {
    ConfigurationHelper config = ConfigurationHelper.getInstance();
    AmazonSQS client;
    if (config.isUseLocalSQS()) {
        String endpoint = "http://localhost:9324";
        String region = "elasticmq";
        String accessKey = "x";
        String secretKey = "x";
        client = AmazonSQSClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey))).withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region)).build();
    } else {
        client = AmazonSQSClientBuilder.defaultClient();
    }
    SQSConnectionFactory connectionFactory = new SQSConnectionFactory(new ProviderConfiguration(), client);
    SQSConnection connection = connectionFactory.createConnection();
    createQueues(connection);
    return connection;
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) ConfigurationHelper(de.sub.goobi.config.ConfigurationHelper) AmazonSQS(com.amazonaws.services.sqs.AmazonSQS) AwsClientBuilder(com.amazonaws.client.builder.AwsClientBuilder) SQSConnectionFactory(com.amazon.sqs.javamessaging.SQSConnectionFactory) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ProviderConfiguration(com.amazon.sqs.javamessaging.ProviderConfiguration) SQSConnection(com.amazon.sqs.javamessaging.SQSConnection)

Example 2 with ProviderConfiguration

use of com.amazon.sqs.javamessaging.ProviderConfiguration in project java-dynamic-sqs-listener by JaidenAshmore.

the class SqsListenersConfiguration method providerConfiguration.

// JMS Beans
/**
 * Set up for JMS to set the number of messages to prefetch.
 *
 * @return the configuration for JMS
 */
@Bean
public ProviderConfiguration providerConfiguration() {
    final ProviderConfiguration providerConfiguration = new ProviderConfiguration();
    // This setting sets how many messages a thread can prefetch to place in it's own queue for processing.
    // Note that this means that if the JmsListener is set to have concurrency 5 and therefore 5 threads are
    // all processing messages than the total number of messages that would be in the queue are
    // 5 * numberOfMessagesToPrefetch
    providerConfiguration.setNumberOfMessagesToPrefetch(5);
    return providerConfiguration;
}
Also used : ProviderConfiguration(com.amazon.sqs.javamessaging.ProviderConfiguration) Bean(org.springframework.context.annotation.Bean)

Aggregations

ProviderConfiguration (com.amazon.sqs.javamessaging.ProviderConfiguration)2 SQSConnection (com.amazon.sqs.javamessaging.SQSConnection)1 SQSConnectionFactory (com.amazon.sqs.javamessaging.SQSConnectionFactory)1 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)1 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 AwsClientBuilder (com.amazonaws.client.builder.AwsClientBuilder)1 AmazonSQS (com.amazonaws.services.sqs.AmazonSQS)1 ConfigurationHelper (de.sub.goobi.config.ConfigurationHelper)1 Bean (org.springframework.context.annotation.Bean)1