Search in sources :

Example 1 with SQSConnectionFactory

use of com.amazon.sqs.javamessaging.SQSConnectionFactory in project kylo by Teradata.

the class SqsConfig method connectionFactory.

@Bean
public SQSConnectionFactory connectionFactory() {
    String regionName = env.getProperty("sqs.region.name");
    SQSConnectionFactory factory = SQSConnectionFactory.builder().withRegionName(regionName).withEndpoint("sqs." + regionName + ".amazonaws.com").withAWSCredentialsProvider(new DefaultAWSCredentialsProviderChain()).build();
    LOG.info("Setup Amazon SQS ConnectionFactory for " + regionName);
    return factory;
}
Also used : DefaultAWSCredentialsProviderChain(com.amazonaws.auth.DefaultAWSCredentialsProviderChain) SQSConnectionFactory(com.amazon.sqs.javamessaging.SQSConnectionFactory) Bean(org.springframework.context.annotation.Bean)

Example 2 with SQSConnectionFactory

use of com.amazon.sqs.javamessaging.SQSConnectionFactory 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 3 with SQSConnectionFactory

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

the class SqsListenersConfiguration method jmsListenerContainerFactory.

/**
 * Create factory for attaching to the SQS Queues.
 *
 * @param amazonSqs             the sqs client
 * @param providerConfiguration configuration for this provided
 * @return the JMS container factory used
 */
@Bean
public JmsListenerContainerFactory<DefaultMessageListenerContainer> jmsListenerContainerFactory(final AmazonSQSAsync amazonSqs, final ProviderConfiguration providerConfiguration) {
    final DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    factory.setConnectionFactory(new SQSConnectionFactory(providerConfiguration, amazonSqs));
    factory.setDestinationResolver(new DynamicDestinationResolver());
    // This sets the default concurrency for each listener but it can be overridden by your JmsListener
    factory.setConcurrency("10");
    factory.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
    return factory;
}
Also used : DefaultJmsListenerContainerFactory(org.springframework.jms.config.DefaultJmsListenerContainerFactory) SQSConnectionFactory(com.amazon.sqs.javamessaging.SQSConnectionFactory) DynamicDestinationResolver(org.springframework.jms.support.destination.DynamicDestinationResolver) Bean(org.springframework.context.annotation.Bean)

Aggregations

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