Search in sources :

Example 1 with SQSConnection

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

the class SqsService method getQueue.

@Override
public Queue getQueue(String queueName) {
    String name = destinationResolver.resolveName(queueName);
    try {
        // Create a new Queue if required
        SQSConnection connection = connectionFactory.createConnection();
        AmazonSQSMessagingClientWrapper client = connection.getWrappedAmazonSQSClient();
        if (!client.queueExists(name)) {
            client.createQueue(name);
        }
        // Queue must already exist
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        return session.createQueue(name);
    } catch (JMSException e) {
        throw new IllegalStateException(e);
    }
}
Also used : AmazonSQSMessagingClientWrapper(com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper) JMSException(javax.jms.JMSException) SQSConnection(com.amazon.sqs.javamessaging.SQSConnection) Session(javax.jms.Session)

Example 2 with SQSConnection

use of com.amazon.sqs.javamessaging.SQSConnection 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)

Aggregations

SQSConnection (com.amazon.sqs.javamessaging.SQSConnection)2 AmazonSQSMessagingClientWrapper (com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper)1 ProviderConfiguration (com.amazon.sqs.javamessaging.ProviderConfiguration)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 JMSException (javax.jms.JMSException)1 Session (javax.jms.Session)1