Example usage for com.amazonaws.services.sqs.model GetQueueUrlRequest setQueueOwnerAWSAccountId

List of usage examples for com.amazonaws.services.sqs.model GetQueueUrlRequest setQueueOwnerAWSAccountId

Introduction

In this page you can find the example usage for com.amazonaws.services.sqs.model GetQueueUrlRequest setQueueOwnerAWSAccountId.

Prototype


public void setQueueOwnerAWSAccountId(String queueOwnerAWSAccountId) 

Source Link

Document

The AWS account ID of the account that created the queue.

Usage

From source file:com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper.java

License:Open Source License

/**
 * Check if the requested queue exists. This function calls
 * <code>GetQueueUrl</code> for the given queue name with the given owner
 * accountId, returning true on success, false if it gets
 * <code>QueueDoesNotExistException</code>.
 * //from   w  w w.ja  va 2  s .  com
 * @param queueName
 *            the queue to check
 * @param queueOwnerAccountId
 *            The AWS accountId of the account that created the queue
 * @return true if the queue exists, false if it doesn't.
 * @throws JMSException
 */
public boolean queueExists(String queueName, String queueOwnerAccountId) throws JMSException {
    try {
        GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(queueName);
        getQueueUrlRequest.setQueueOwnerAWSAccountId(queueOwnerAccountId);
        amazonSQSClient.getQueueUrl(getQueueUrlRequest);
        return true;
    } catch (QueueDoesNotExistException e) {
        return false;
    } catch (AmazonClientException e) {
        throw handleException(e, "getQueueUrl");
    }
}

From source file:com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper.java

License:Open Source License

/**
 * Gets the queueUrl of a queue given a queue name owned by the provided accountId.
 * //from   ww w .  ja  v a  2  s . c  o m
 * @param queueName
 * @param queueOwnerAccountId The AWS accountId of the account that created the queue
 * @return The response from the GetQueueUrl service method, as returned by
 *         AmazonSQS, which will include queue`s URL
 * @throws JMSException
 */
public GetQueueUrlResult getQueueUrl(String queueName, String queueOwnerAccountId) throws JMSException {
    GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(queueName);
    getQueueUrlRequest.setQueueOwnerAWSAccountId(queueOwnerAccountId);
    return getQueueUrl(getQueueUrlRequest);
}

From source file:org.apache.camel.component.aws.sqs.SqsEndpoint.java

License:Apache License

@Override
protected void doStart() throws Exception {
    client = getConfiguration().getAmazonSQSClient() != null ? getConfiguration().getAmazonSQSClient()
            : getClient();/*www  . j a  va  2s  .  c o  m*/

    // If both region and Account ID is provided the queue URL can be built manually.
    // This allows accessing queues where you don't have permission to list queues or query queues
    if (configuration.getRegion() != null && configuration.getQueueOwnerAWSAccountId() != null) {
        queueUrl = "https://sqs." + configuration.getRegion() + ".amazonaws.com/"
                + configuration.getQueueOwnerAWSAccountId() + "/" + configuration.getQueueName();
    } else if (configuration.getQueueOwnerAWSAccountId() != null) {
        GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest();
        getQueueUrlRequest.setQueueName(configuration.getQueueName());
        getQueueUrlRequest.setQueueOwnerAWSAccountId(configuration.getQueueOwnerAWSAccountId());
        GetQueueUrlResult getQueueUrlResult = client.getQueueUrl(getQueueUrlRequest);
        queueUrl = getQueueUrlResult.getQueueUrl();
    } else {
        // check whether the queue already exists
        ListQueuesResult listQueuesResult = client.listQueues();
        for (String url : listQueuesResult.getQueueUrls()) {
            if (url.endsWith("/" + configuration.getQueueName())) {
                queueUrl = url;
                LOG.trace("Queue available at '{}'.", queueUrl);
                break;
            }
        }
    }

    if (queueUrl == null) {
        createQueue(client);
    } else {
        updateQueueAttributes(client);
    }
}