com.amazonaws.services.sqs.model.CreateQueueResult Java Examples

The following examples show how to use com.amazonaws.services.sqs.model.CreateQueueResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SqsIOTest.java    From beam with Apache License 2.0 6 votes vote down vote up
@Override
protected void before() {
  sqsRestServer = SQSRestServerBuilder.start();

  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();
  final CreateQueueResult queue = client.createQueue("test");
  queueUrl = queue.getQueueUrl();
}
 
Example #2
Source File: LocalstackContainerTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@Test
public void sqsTestOverBridgeNetwork() {
    AmazonSQS sqs = AmazonSQSClientBuilder.standard()
        .withEndpointConfiguration(localstack.getEndpointConfiguration(SQS))
        .withCredentials(localstack.getDefaultCredentialsProvider())
        .build();

    CreateQueueResult queueResult = sqs.createQueue("baz");
    String fooQueueUrl = queueResult.getQueueUrl();
    assertThat("Created queue has external hostname URL", fooQueueUrl,
        containsString("http://" + DockerClientFactory.instance().dockerHostIpAddress() + ":" + localstack.getMappedPort(SQS.getPort())));

    sqs.sendMessage(fooQueueUrl, "test");
    final long messageCount = sqs.receiveMessage(fooQueueUrl).getMessages().stream()
        .filter(message -> message.getBody().equals("test"))
        .count();
    assertEquals("the sent message can be received", 1L, messageCount);
}
 
Example #3
Source File: AwsGlacierInventoryRetriever.java    From core with GNU General Public License v3.0 5 votes vote down vote up
/**
 * For retrieving vault inventory. For initializing SQS for determining when
 * job completed. Does nothing if member snsTopicName is null. Sets members
 * sqsQueueURL, sqsQueueARN, and sqsClient.
 */
   private void setupSQS() {
	// If no sqsQueueName setup then simply return
	if (sqsQueueName == null)
		return;

	CreateQueueRequest request = new CreateQueueRequest()
			.withQueueName(sqsQueueName);
	CreateQueueResult result = sqsClient.createQueue(request);
	sqsQueueURL = result.getQueueUrl();

	GetQueueAttributesRequest qRequest = new GetQueueAttributesRequest()
			.withQueueUrl(sqsQueueURL).withAttributeNames("QueueArn");

	GetQueueAttributesResult qResult = sqsClient
			.getQueueAttributes(qRequest);
	sqsQueueARN = qResult.getAttributes().get("QueueArn");

	Policy sqsPolicy = new Policy().withStatements(new Statement(
			Effect.Allow).withPrincipals(Principal.AllUsers)
			.withActions(SQSActions.SendMessage)
			.withResources(new Resource(sqsQueueARN)));
	Map<String, String> queueAttributes = new HashMap<String, String>();
	queueAttributes.put("Policy", sqsPolicy.toJson());
	sqsClient.setQueueAttributes(new SetQueueAttributesRequest(sqsQueueURL,
			queueAttributes));
}
 
Example #4
Source File: SqsExecutor.java    From spring-integration-aws with MIT License 5 votes vote down vote up
private void createQueueIfNotExists() {
	for (String qUrl : sqsClient.listQueues().getQueueUrls()) {
		if (qUrl.contains(queueName)) {
			queueUrl = qUrl;
			break;
		}
	}
	if (queueUrl == null) {
		CreateQueueRequest request = new CreateQueueRequest(queueName);
		Map<String, String> queueAttributes = new HashMap<String, String>();
		queueAttributes.put("ReceiveMessageWaitTimeSeconds", Integer
				.valueOf(receiveMessageWaitTimeout).toString());
		if (messageDelay != null) {
			queueAttributes.put("DelaySeconds", messageDelay.toString());
		}
		if (maximumMessageSize != null) {
			queueAttributes.put("MaximumMessageSize",
					maximumMessageSize.toString());
		}
		if (messageRetentionPeriod != null) {
			queueAttributes.put("MessageRetentionPeriod",
					messageRetentionPeriod.toString());
		}
		if (visibilityTimeout != null) {
			queueAttributes.put("VisibilityTimeout",
					visibilityTimeout.toString());
		}
		request.setAttributes(queueAttributes);
		CreateQueueResult result = sqsClient.createQueue(request);
		queueUrl = result.getQueueUrl();
		log.debug("New queue available at: " + queueUrl);
	} else {
		log.debug("Queue already exists: " + queueUrl);
	}

	resolveQueueArn();
}
 
Example #5
Source File: SpringCloudSQSLiveTest.java    From tutorials with MIT License 5 votes vote down vote up
@BeforeClass
public static void setupAwsResources() {

    sendQueueName = UUID.randomUUID().toString();
    receiveQueueName = SpringCloudSQS.QUEUE_NAME;

    AmazonSQS amazonSQS = SpringCloudAwsTestUtil.amazonSQS();

    CreateQueueResult receiveQueue = amazonSQS.createQueue(receiveQueueName);
    receiveQueueUrl = receiveQueue.getQueueUrl();

    CreateQueueResult sendQueue = amazonSQS.createQueue(sendQueueName);
    sendQueueURl = sendQueue.getQueueUrl();
}
 
Example #6
Source File: TOCQueue.java    From s3-bucket-loader with Apache License 2.0 5 votes vote down vote up
/**
 * Note here we attempt to the TOCQueue which may take some time to be shown as available
 * @param isConsumer
 * @param maxAttempts
 * @throws Exception
 */
public void connectToQueue(boolean isConsumer, int maxAttempts) throws Exception{
	
	for (int i=0; i<maxAttempts; i++) {
		
		logger.debug("connectToQueue() attempt: " + (i+1));
		
		ListQueuesResult queuesResult = sqsClient.listQueues();
		if (queuesResult != null) {
			for (String queueUrl : queuesResult.getQueueUrls()) {
				if (queueUrl.indexOf(sqsQueueName) != -1) {
					tocQueueUrl = queueUrl;
					break;
				}
			}
		}
		
		// if consumer, retry, otherwise is master, so just exit quick to create...
		if (tocQueueUrl == null && isConsumer) {
			Thread.currentThread().sleep(1000);
			continue;
		} else {
			break; // exit;
		}
	}
	
	if (tocQueueUrl == null && !isConsumer) {
		CreateQueueResult createQueueResult = sqsClient.createQueue(sqsQueueName);
		this.tocQueueUrl = createQueueResult.getQueueUrl();
		
	} else if (tocQueueUrl == null) {
		throw new Exception("TOCQueue() isConsumer:"+ isConsumer+ " cannot start, sqsQueueName has yet to be created by master?: " + sqsQueueName);
	}
}
 
Example #7
Source File: SQSImpl.java    From aws-sdk-java-resources with Apache License 2.0 5 votes vote down vote up
@Override
public Queue createQueue(String queueName, ResultCapture<CreateQueueResult>
        extractor) {

    CreateQueueRequest request = new CreateQueueRequest()
        .withQueueName(queueName);
    return createQueue(request, extractor);
}
 
Example #8
Source File: SQSImpl.java    From aws-sdk-java-resources with Apache License 2.0 5 votes vote down vote up
@Override
public Queue createQueue(CreateQueueRequest request,
        ResultCapture<CreateQueueResult> extractor) {

    ActionResult result = service.performAction("CreateQueue", request,
            extractor);

    if (result == null) return null;
    return new QueueImpl(result.getResource());
}
 
Example #9
Source File: DynamicQueueUrlDestinationResolverTest.java    From spring-cloud-aws with Apache License 2.0 5 votes vote down vote up
@Test
void testAutoCreate() throws Exception {
	AmazonSQS amazonSqs = mock(AmazonSQS.class);
	String queueUrl = "https://foo/bar";
	when(amazonSqs.createQueue(new CreateQueueRequest("foo")))
			.thenReturn(new CreateQueueResult().withQueueUrl(queueUrl));

	DynamicQueueUrlDestinationResolver dynamicQueueDestinationResolver = new DynamicQueueUrlDestinationResolver(
			amazonSqs);
	dynamicQueueDestinationResolver.setAutoCreate(true);
	assertThat(dynamicQueueDestinationResolver.resolveDestination("foo"))
			.isEqualTo(queueUrl);
}
 
Example #10
Source File: DynamicQueueUrlDestinationResolver.java    From spring-cloud-aws with Apache License 2.0 5 votes vote down vote up
@Override
public String resolveDestination(String name) throws DestinationResolutionException {
	String queueName = name;

	if (this.resourceIdResolver != null) {
		queueName = this.resourceIdResolver.resolveToPhysicalResourceId(name);
	}

	if (isValidQueueUrl(queueName)) {
		return queueName;
	}

	if (this.autoCreate) {
		// Auto-create is fine to be called even if the queue exists.
		CreateQueueResult createQueueResult = this.amazonSqs
				.createQueue(new CreateQueueRequest(queueName));
		return createQueueResult.getQueueUrl();
	}
	else {
		try {
			GetQueueUrlResult getQueueUrlResult = this.amazonSqs
					.getQueueUrl(new GetQueueUrlRequest(queueName));
			return getQueueUrlResult.getQueueUrl();
		}
		catch (QueueDoesNotExistException e) {
			throw toDestinationResolutionException(e);
		}
	}
}
 
Example #11
Source File: AmazonSQSTemporaryQueuesClient.java    From amazon-sqs-java-temporary-queues-client with Apache License 2.0 5 votes vote down vote up
@Override
public CreateQueueResult createQueue(CreateQueueRequest request) {
    // Check for unsupported queue attributes first
    Set<String> unsupportedQueueAttributes = new HashSet<>(request.getAttributes().keySet());
    unsupportedQueueAttributes.removeAll(SUPPORTED_QUEUE_ATTRIBUTES);
    if (!unsupportedQueueAttributes.isEmpty()) {
        throw new IllegalArgumentException("Cannot create a temporary queue with the following attributes: "
                + String.join(", ", unsupportedQueueAttributes));
    }

    Map<String, String> extraQueueAttributes = new HashMap<>();
    // Add the retention period to both the host queue and each virtual queue
    extraQueueAttributes.put(AmazonSQSIdleQueueDeletingClient.IDLE_QUEUE_RETENTION_PERIOD, QUEUE_RETENTION_PERIOD_SECONDS);
    String hostQueueUrl = hostQueueUrls.computeIfAbsent(request.getAttributes(), attributes -> {
        CreateQueueRequest hostQueueCreateRequest = SQSQueueUtils.copyWithExtraAttributes(request, extraQueueAttributes);
        hostQueueCreateRequest.setQueueName(prefix + '-' + hostQueueUrls.size());
        return amazonSqsToBeExtended.createQueue(hostQueueCreateRequest).getQueueUrl();
    });

    extraQueueAttributes.put(AmazonSQSVirtualQueuesClient.VIRTUAL_QUEUE_HOST_QUEUE_ATTRIBUTE, hostQueueUrl);
    // The host queue takes care of all the other queue attributes, so don't specify them when creating the virtual
    // queue or else the client may think we're trying to set them independently!
    CreateQueueRequest createVirtualQueueRequest = new CreateQueueRequest()
            .withQueueName(request.getQueueName())
            .withAttributes(extraQueueAttributes);
    return amazonSqsToBeExtended.createQueue(createVirtualQueueRequest);
}
 
Example #12
Source File: AmazonSQSIdleQueueDeletingClient.java    From amazon-sqs-java-temporary-queues-client with Apache License 2.0 5 votes vote down vote up
@Override
public CreateQueueResult createQueue(CreateQueueRequest request) {
    Map<String, String> attributes = new HashMap<>(request.getAttributes());
    Optional<Long> retentionPeriod = getRetentionPeriod(attributes);
    if (!retentionPeriod.isPresent()) {
        return super.createQueue(request);
    }

    String queueName = request.getQueueName();
    if (!queueName.startsWith(queueNamePrefix)) {
        throw new IllegalArgumentException();
    }

    CreateQueueRequest superRequest = request.clone()
            .withQueueName(queueName)
            .withAttributes(attributes);

    CreateQueueResult result = super.createQueue(superRequest);
    String queueUrl = result.getQueueUrl();

    String retentionPeriodString = retentionPeriod.get().toString();
    amazonSqsToBeExtended.tagQueue(queueUrl,
            Collections.singletonMap(IDLE_QUEUE_RETENTION_PERIOD_TAG, retentionPeriodString));

    // TODO-RS: Filter more carefully to all attributes valid for createQueue 
    List<String> attributeNames = Arrays.asList(QueueAttributeName.ReceiveMessageWaitTimeSeconds.toString(),
                                                QueueAttributeName.VisibilityTimeout.toString());
    Map<String, String> createdAttributes = amazonSqsToBeExtended.getQueueAttributes(queueUrl, attributeNames).getAttributes();
    createdAttributes.put(IDLE_QUEUE_RETENTION_PERIOD, retentionPeriodString);

    QueueMetadata metadata = new QueueMetadata(queueName, queueUrl, createdAttributes);
    queues.put(queueUrl, metadata);

    metadata.heartbeater = executor.scheduleAtFixedRate(() -> heartbeatToQueue(queueUrl), 
            0, heartbeatIntervalSeconds, TimeUnit.SECONDS);

    return result;
}
 
Example #13
Source File: AmazonSQSVirtualQueuesClient.java    From amazon-sqs-java-temporary-queues-client with Apache License 2.0 5 votes vote down vote up
@Override
public CreateQueueResult createQueue(CreateQueueRequest request) {
    String hostQueueUrl = request.getAttributes().get(VIRTUAL_QUEUE_HOST_QUEUE_ATTRIBUTE);
    if (hostQueueUrl == null) {
        return amazonSqsToBeExtended.createQueue(request);
    }

    Map<String, String> attributes = new HashMap<>(request.getAttributes());
    attributes.remove(VIRTUAL_QUEUE_HOST_QUEUE_ATTRIBUTE);

    Optional<Long> retentionPeriod = AmazonSQSIdleQueueDeletingClient.getRetentionPeriod(attributes);

    if (!attributes.isEmpty()) {
        throw new IllegalArgumentException("Virtual queues do not support setting these queue attributes independently of their host queues: "
                + attributes.keySet());
    }

    HostQueue host = hostQueues.computeIfAbsent(hostQueueUrl, HostQueue::new);
    VirtualQueue virtualQueue = new VirtualQueue(host, request.getQueueName(), retentionPeriod);

    // There is clearly a race condition here between checking the size and
    // adding to the map, but that's fine since this is just a loose upper bound
    // and it avoids synchronizing all calls on something like an AtomicInteger.
    // The worse case scenario is that the map has X entries more than the maximum
    // where X is the number of threads concurrently creating queues.
    if (virtualQueues.size() > MAXIMUM_VIRTUAL_QUEUES_COUNT) {
        throw new IllegalStateException("Cannot create virtual queue: the number of virtual queues would exceed the maximum of "
                + MAXIMUM_VIRTUAL_QUEUES_COUNT);
    }
    virtualQueues.put(virtualQueue.getID().getVirtualQueueName(), virtualQueue);

    if (LOG.isDebugEnabled()) {
        LOG.debug(String.format("Total Virtual Queue Created is %s and Queue Name is %s", virtualQueues.size(), virtualQueue.getID().getVirtualQueueName()));
    }

    return new CreateQueueResult().withQueueUrl(virtualQueue.getID().getQueueUrl());
}
 
Example #14
Source File: ApplicationTest.java    From examples with Apache License 2.0 5 votes vote down vote up
private void writeMsg(String[] msgs)
{
  CreateQueueResult res = sqs.createQueue(currentQueueName);

  currentQueueUrl = res.getQueueUrl();

  // we should purge the queue first
  PurgeQueueRequest purgeReq = new PurgeQueueRequest(currentQueueUrl);
  sqs.purgeQueue(purgeReq);
  for (String text : msgs) {
    sqs.sendMessage(currentQueueUrl, text);
  }
}
 
Example #15
Source File: SendReceiveMessages.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
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());
    }
}
 
Example #16
Source File: VisibilityTimeout.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
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, 60 * 60); //1 hour

    // change visibility timeout (multiple)
    changeMessageVisibilityMultiple(queue_url, 30 * 60 ); //30 minutes
}
 
Example #17
Source File: SQSObservableQueue.java    From conductor with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
String getOrCreateQueue() {
       List<String> queueUrls = listQueues(queueName);
	if (queueUrls == null || queueUrls.isEmpty()) {
           CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName(queueName);
           CreateQueueResult result = client.createQueue(createQueueRequest);
           return result.getQueueUrl();
	} else {
           return queueUrls.get(0);
       }
   }
 
Example #18
Source File: MockSQS.java    From amazon-sqs-java-temporary-queues-client with Apache License 2.0 5 votes vote down vote up
@Override
public CreateQueueResult createQueue(CreateQueueRequest request) {
    String queueName = request.getQueueName();
    String queueUrl = accountPrefix + queueName;
    queues.put(queueName, new MockSQSQueue(queueName));
    return new CreateQueueResult().withQueueUrl(queueUrl);
}
 
Example #19
Source File: SQSTestBase.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
public void produceMsg(String[] msgs, boolean purgeFirst) throws Exception
{
  CreateQueueResult res = sqs.createQueue(getCurrentQueueName());
  if (purgeFirst) {
    PurgeQueueRequest purgeReq = new PurgeQueueRequest(res.getQueueUrl());
    sqs.purgeQueue(purgeReq);
  }
  for (String text : msgs) {
    sqs.sendMessage(res.getQueueUrl(), text);
  }
}
 
Example #20
Source File: SQSImpl.java    From aws-sdk-java-resources with Apache License 2.0 4 votes vote down vote up
@Override
public Queue createQueue(String queueName) {
    return createQueue(queueName, (ResultCapture<CreateQueueResult>)null);
}
 
Example #21
Source File: BeanstalkConnector.java    From cloudml with GNU Lesser General Public License v3.0 4 votes vote down vote up
public String createQueue(String name){
    CreateQueueRequest request=new CreateQueueRequest();
    request.setQueueName(name);
    CreateQueueResult res= sqsClient.createQueue(request);
    return res.getQueueUrl();
}
 
Example #22
Source File: ControlChannel.java    From s3-bucket-loader with Apache License 2.0 4 votes vote down vote up
public void connectToTopic(boolean callerIsMaster, int maxAttempts, String userAccountPrincipalId, String userARN) throws Exception {
	
	
	// try up to max attempts to connect to pre-existing topic
	for (int i=0; i<maxAttempts; i++) {
		
		logger.debug("connectToTopic() attempt: " + (i+1));
		
		ListTopicsResult listResult = snsClient.listTopics();
		List<Topic> topics = listResult.getTopics();
		
		while(topics != null) {
			
			for (Topic topic : topics) {

				// note we do index of match....
				if (topic.getTopicArn().indexOf(snsControlTopicName) != -1) {
					snsTopicARN = topic.getTopicArn();
					logger.info("Found existing SNS topic by name: "+snsControlTopicName + " @ " + snsTopicARN);
					break;
				}
			}

			String nextToken = listResult.getNextToken();
			
			if (nextToken != null && snsTopicARN == null) {
				listResult = snsClient.listTopics(nextToken);
				topics = listResult.getTopics();
				
			} else {
				break;
			}
		}
		
		// if consumer, retry, otherwise is master, so just exit quick to create...
		if (snsTopicARN == null && !callerIsMaster) {
			Thread.currentThread().sleep(1000);
			continue;
		} else {
			break; // exit;
		}
	}
	
	
	
	// if master only he can create...
	if (snsTopicARN == null && callerIsMaster) {
		this.snsControlTopicName = this.snsControlTopicName.substring(0,(snsControlTopicName.length() > 80 ? 80 : this.snsControlTopicName.length()));
		
		logger.info("Attempting to create new SNS control channel topic by name: "+this.snsControlTopicName);
		
		CreateTopicResult createTopicResult = snsClient.createTopic(this.snsControlTopicName);
		snsTopicARN = createTopicResult.getTopicArn();
		snsClient.addPermission(snsTopicARN, "Permit_SNSAdd", 
								Arrays.asList(new String[]{userARN}), 
								Arrays.asList(new String[]{"Publish","Subscribe","Receive"}));
		logger.info("Created new SNS control channel topic by name: "+this.snsControlTopicName + " @ " + snsTopicARN);
		
	} else if (snsTopicARN == null) {
		throw new Exception("Worker() cannot start, snsControlTopicName has yet to be created by master?: " + this.snsControlTopicName);
	}
	
	// http://www.jorgjanke.com/2013/01/aws-sns-topic-subscriptions-with-sqs.html
	
	// create SQS queue to get SNS notifications (max 80 len)
	String prefix =  ("s3bktLoaderCC_" + mySourceIdentifier);
	String sqsQueueName = prefix.substring(0,(prefix.length() > 80 ? 80 : prefix.length()));
	
	CreateQueueResult createQueueResult = sqsClient.createQueue(sqsQueueName);
	this.sqsQueueUrl = createQueueResult.getQueueUrl();
	this.sqsQueueARN = sqsClient.getQueueAttributes(sqsQueueUrl, Arrays.asList(new String[]{"QueueArn"})).getAttributes().get("QueueArn");

	Statement statement = new Statement(Effect.Allow)
							.withActions(SQSActions.SendMessage)
							 .withPrincipals(new Principal("*"))
							 .withConditions(ConditionFactory.newSourceArnCondition(snsTopicARN))
							 .withResources(new Resource(sqsQueueARN));
	Policy policy = new Policy("SubscriptionPermission").withStatements(statement);

	HashMap<String, String> attributes = new HashMap<String, String>();
	attributes.put("Policy", policy.toJson());
	SetQueueAttributesRequest request = new SetQueueAttributesRequest(sqsQueueUrl, attributes);
	sqsClient.setQueueAttributes(request);

	logger.info("Created SQS queue: " + sqsQueueARN + " @ " + sqsQueueUrl);
	
	// subscribe our SQS queue to the SNS:s3MountTest topic
	SubscribeResult subscribeResult = snsClient.subscribe(snsTopicARN,"sqs",sqsQueueARN);
	snsSubscriptionARN = subscribeResult.getSubscriptionArn();
	logger.info("Subscribed for messages from SNS control channel:" + snsTopicARN + " ----> SQS: "+sqsQueueARN);
	logger.info("Subscription ARN: " + snsSubscriptionARN);
	
	this.consumerThread = new Thread(this,"ControlChannel msg consumer thread");
	this.consumerThread.start();

	logger.info("\n-------------------------------------------\n" +
				"CONTROL CHANNEL: ALL SNS/SQS resources hooked up OK\n" +
				"-------------------------------------------\n");
}
 
Example #23
Source File: AbstractAmazonSQSClientWrapper.java    From amazon-sqs-java-temporary-queues-client with Apache License 2.0 4 votes vote down vote up
@Override
public CreateQueueResult createQueue(CreateQueueRequest request) {
    request.getRequestClientOptions().appendUserAgent(userAgent);
    return amazonSqsToBeExtended.createQueue(request);
}
 
Example #24
Source File: AmazonSQSMessagingClientWrapper.java    From amazon-sqs-java-messaging-lib with Apache License 2.0 3 votes vote down vote up
/**
 * Calls <code>createQueue</code> to create the queue with the provided queue attributes
 * if any, and wraps <code>AmazonClientException</code>
 * 
 * @param createQueueRequest
 *            Container for the necessary parameters to execute the
 *            createQueue service method on AmazonSQS.
 * @return The response from the createQueue service method, as returned by
 *         AmazonSQS. This call creates a new queue, or returns the URL of
 *         an existing one.
 * @throws JMSException
 */
public CreateQueueResult createQueue(CreateQueueRequest createQueueRequest) throws JMSException {
    try {
        prepareRequest(createQueueRequest);
        return amazonSQSClient.createQueue(createQueueRequest);
    } catch (AmazonClientException e) {
        throw handleException(e, "createQueue");   
    }    
}
 
Example #25
Source File: SQS.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Performs the <code>CreateQueue</code> action and use a ResultCapture to
 * retrieve the low-level client response.
 *
 * <p>
 *
 * @return The <code>Queue</code> resource object associated with the result
 *         of this action.
 * @see CreateQueueRequest
 */
com.amazonaws.resources.sqs.Queue createQueue(CreateQueueRequest request,
        ResultCapture<CreateQueueResult> extractor);
 
Example #26
Source File: AmazonSQSMessagingClientWrapper.java    From amazon-sqs-java-messaging-lib with Apache License 2.0 2 votes vote down vote up
/**
 * Calls <code>createQueue</code> to create the queue with the default queue attributes,
 * and wraps <code>AmazonClientException</code>
 * 
 * @param queueName
 * @return The response from the createQueue service method, as returned by
 *         AmazonSQS. This call creates a new queue, or returns the URL of
 *         an existing one.
 * @throws JMSException
 */
public CreateQueueResult createQueue(String queueName) throws JMSException {
    return createQueue(new CreateQueueRequest(queueName));
}
 
Example #27
Source File: SQS.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * The convenient method form for the <code>CreateQueue</code> action.
 *
 * @see #createQueue(CreateQueueRequest, ResultCapture)
 */
com.amazonaws.resources.sqs.Queue createQueue(String queueName,
        ResultCapture<CreateQueueResult> extractor);
 
Example #28
Source File: AmazonSQSExtendedClientBase.java    From amazon-sqs-java-extended-client-lib with Apache License 2.0 2 votes vote down vote up
/**
 * <p>
 * Creates a new queue, or returns the URL of an existing one. When you
 * request <code>CreateQueue</code> , you provide a name for the queue. To
 * successfully create a new queue, you must provide a name that is unique
 * within the scope of your own queues.
 * </p>
 * <p>
 * <b>NOTE:</b> If you delete a queue, you must wait at least 60 seconds
 * before creating a queue with the same name.
 * </p>
 * <p>
 * You may pass one or more attributes in the request. If you do not provide
 * a value for any attribute, the queue will have the default value for that
 * attribute. Permitted attributes are the same that can be set using
 * SetQueueAttributes.
 * </p>
 * <p>
 * <b>NOTE:</b> Use GetQueueUrl to get a queue's URL. GetQueueUrl requires
 * only the QueueName parameter.
 * </p>
 * <p>
 * If you provide the name of an existing queue, along with the exact names
 * and values of all the queue's attributes, <code>CreateQueue</code>
 * returns the queue URL for the existing queue. If the queue name,
 * attribute names, or attribute values do not match an existing queue,
 * <code>CreateQueue</code> returns an error.
 * </p>
 * <p>
 * <b>NOTE:</b>Some API actions take lists of parameters. These lists are
 * specified using the param.n notation. Values of n are integers starting
 * from 1. For example, a parameter list with two elements looks like this:
 * </p>
 * <p>
 * <code>&Attribute.1=this</code>
 * </p>
 * <p>
 * <code>&Attribute.2=that</code>
 * </p>
 * 
 * @param queueName
 *            The name for the queue to be created.
 * 
 * @return The response from the CreateQueue service method, as returned by
 *         AmazonSQS.
 * 
 * @throws QueueNameExistsException
 * @throws QueueDeletedRecentlyException
 *
 * @throws AmazonClientException
 *             If any internal errors are encountered inside the client
 *             while attempting to make the request or handle the response.
 *             For example if a network connection is not available.
 * @throws AmazonServiceException
 *             If an error response is returned by AmazonSQS indicating
 *             either a problem with the data in the request, or a server
 *             side issue.
 */
public CreateQueueResult createQueue(String queueName) throws AmazonServiceException, AmazonClientException {

	return amazonSqsToBeExtended.createQueue(queueName);
}
 
Example #29
Source File: AmazonSQSExtendedClientBase.java    From amazon-sqs-java-extended-client-lib with Apache License 2.0 2 votes vote down vote up
/**
 * <p>
 * Creates a new queue, or returns the URL of an existing one. When you
 * request <code>CreateQueue</code> , you provide a name for the queue. To
 * successfully create a new queue, you must provide a name that is unique
 * within the scope of your own queues.
 * </p>
 * <p>
 * <b>NOTE:</b> If you delete a queue, you must wait at least 60 seconds
 * before creating a queue with the same name.
 * </p>
 * <p>
 * You may pass one or more attributes in the request. If you do not provide
 * a value for any attribute, the queue will have the default value for that
 * attribute. Permitted attributes are the same that can be set using
 * SetQueueAttributes.
 * </p>
 * <p>
 * <b>NOTE:</b> Use GetQueueUrl to get a queue's URL. GetQueueUrl requires
 * only the QueueName parameter.
 * </p>
 * <p>
 * If you provide the name of an existing queue, along with the exact names
 * and values of all the queue's attributes, <code>CreateQueue</code>
 * returns the queue URL for the existing queue. If the queue name,
 * attribute names, or attribute values do not match an existing queue,
 * <code>CreateQueue</code> returns an error.
 * </p>
 * <p>
 * <b>NOTE:</b>Some API actions take lists of parameters. These lists are
 * specified using the param.n notation. Values of n are integers starting
 * from 1. For example, a parameter list with two elements looks like this:
 * </p>
 * <p>
 * <code>&Attribute.1=this</code>
 * </p>
 * <p>
 * <code>&Attribute.2=that</code>
 * </p>
 *
 * @param createQueueRequest
 *            Container for the necessary parameters to execute the
 *            CreateQueue service method on AmazonSQS.
 * 
 * @return The response from the CreateQueue service method, as returned by
 *         AmazonSQS.
 * 
 * @throws QueueNameExistsException
 * @throws QueueDeletedRecentlyException
 *
 * @throws AmazonClientException
 *             If any internal errors are encountered inside the client
 *             while attempting to make the request or handle the response.
 *             For example if a network connection is not available.
 * @throws AmazonServiceException
 *             If an error response is returned by AmazonSQS indicating
 *             either a problem with the data in the request, or a server
 *             side issue.
 */
public CreateQueueResult createQueue(CreateQueueRequest createQueueRequest) throws AmazonServiceException,
		AmazonClientException {

	return amazonSqsToBeExtended.createQueue(createQueueRequest);
}