Package com.amazonaws.services.sqs.model

Examples of com.amazonaws.services.sqs.model.GetQueueAttributesRequest


    public void testGetSetQueueAttributes() throws PersistenceException, InterruptedException {
     
        String queueUrl = getQueueUrl(1, USR.USER1);
        cqs1.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, attributeParams));

        GetQueueAttributesRequest getQueueAttributesRequest = new GetQueueAttributesRequest();
        getQueueAttributesRequest.setQueueUrl(queueUrl);
        getQueueAttributesRequest.setAttributeNames(Arrays.asList("VisibilityTimeout", "MessageRetentionPeriod", "All"));
        GetQueueAttributesResult result = cqs1.getQueueAttributes(getQueueAttributesRequest);
        assertTrue(result.getAttributes().get("MessageRetentionPeriod").equals("600"));
        assertTrue(result.getAttributes().get("VisibilityTimeout").equals("30"));
       
        SetQueueAttributesRequest setQueueAttributesRequest = new SetQueueAttributesRequest();
        setQueueAttributesRequest.setQueueUrl(queueUrl);
        HashMap<String, String> attributes = new HashMap<String, String>();
        attributes.put("MessageRetentionPeriod", "300");
        attributes.put("VisibilityTimeout", "80");
        attributes.put("MaximumMessageSize", "10240");
        attributes.put("DelaySeconds", "100");
        String policy = "{\"Version\":\"2008-10-17\",\"Id\":\""+queueUrl+"/SQSDefaultPolicy\",\"Statement\":[{\"Sid\":\"test\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\""+user1.getUserId()+"\"},\"Action\":\"CQS:SendMessage\",\"Resource\":\""+com.comcast.cqs.util.Util.getArnForAbsoluteQueueUrl(queueUrl)+"\"}]}";
        attributes.put("Policy", policy);
        setQueueAttributesRequest.setAttributes(attributes);
        cqs1.setQueueAttributes(setQueueAttributesRequest);

        result = cqs1.getQueueAttributes(getQueueAttributesRequest);
        assertTrue("Expected retention period of 300 sec, instead found " + result.getAttributes().get("MessageRetentionPeriod"), result.getAttributes().get("MessageRetentionPeriod").equals("300"));
        assertTrue("Expected visibility timeout to be 80 sec, instead found " + result.getAttributes().get("VisibilityTimeout"), result.getAttributes().get("VisibilityTimeout").equals("80"));
        assertTrue("Expected max message size to be 10240, instead found " + result.getAttributes().get("MaximumMessageSize"), result.getAttributes().get("MaximumMessageSize").equals("10240"));
        assertTrue("Expected delay seconds to be 100, instead found " + result.getAttributes().get("DelaySeconds"), result.getAttributes().get("DelaySeconds").equals("100"));

        attributes = new HashMap<String, String>(){ {put("VisibilityTimeout", "100");}};
        setQueueAttributesRequest.setAttributes(attributes);
        cqs1.setQueueAttributes(setQueueAttributesRequest);
       
        result = cqs1.getQueueAttributes(getQueueAttributesRequest);
        assertTrue("Expected visibility timeout to be 100 sec, instead found " + result.getAttributes().get("VisibilityTimeout"), result.getAttributes().get("VisibilityTimeout").equals("100"));

        // try triggering missing parameter error
       
        try {

          setQueueAttributesRequest = new SetQueueAttributesRequest();
          setQueueAttributesRequest.setQueueUrl(queueUrl);
          cqs1.setQueueAttributes(setQueueAttributesRequest);
          fail("missing expected exception");
         
        } catch (AmazonServiceException ase) {
            assertTrue("Did not receive missing parameter exception", ase.getErrorCode().equals(CQSErrorCodes.MissingParameter.getCMBCode()));
        }
       
        // try trigger unknown attribute name error
       
        try {

          getQueueAttributesRequest = new GetQueueAttributesRequest();
          getQueueAttributesRequest.setQueueUrl(queueUrl);
          getQueueAttributesRequest.setAttributeNames(Arrays.asList("all"));
          cqs1.getQueueAttributes(getQueueAttributesRequest);
          fail("missing expected exception");

        } catch (AmazonServiceException ase) {
            assertTrue(ase.getErrorCode().equals(CQSErrorCodes.InvalidAttributeName.getCMBCode()));
View Full Code Here


        addPermissionRequest.setLabel("testLabel2");
        addPermissionRequest.setActions(Arrays.asList("SendMessage", "GetQueueUrl"));
        cqs1.addPermission(addPermissionRequest);

        GetQueueAttributesRequest getQueueAttributesRequest = new GetQueueAttributesRequest();
        getQueueAttributesRequest.setAttributeNames(Arrays.asList("All"));
        getQueueAttributesRequest.setQueueUrl(queueUrl);
        GetQueueAttributesResult res = cqs1.getQueueAttributes(getQueueAttributesRequest);
        res = cqs1.getQueueAttributes(getQueueAttributesRequest);
       
        assertTrue("Did not find labels testLabel and testLabel2", res.toString().contains("testLabel") && res.toString().contains("testLabel2"));
       
View Full Code Here

     
      while (true) {
        try {
          Thread.currentThread().sleep(monitorDelay);
          long start = System.currentTimeMillis();
          GetQueueAttributesRequest getQueueAttributesRequest = new GetQueueAttributesRequest(queueUrl);
          Set<String> attribs = new TreeSet<String>();
          attribs.add("All");
          getQueueAttributesRequest.setAttributeNames(attribs);
          GetQueueAttributesResult result = cqs1.getQueueAttributes(getQueueAttributesRequest);
          int numMsg = Integer.valueOf(result.getAttributes().get("ApproximateNumberOfMessages"));
          int numInvisible = Integer.valueOf(result.getAttributes().get("ApproximateNumberOfMessagesNotVisible"));
          if (numMsg > maxQueueDepth || numInvisible > maxQueueDepth) {
            if (sendDelay == 10) {
View Full Code Here

    }
   
    Map<String, String> attributes = null;
   
    try {
      GetQueueAttributesRequest getQueueAttributesRequest = new GetQueueAttributesRequest(queueUrl);
      getQueueAttributesRequest.setAttributeNames(Arrays.asList("Policy"));
      GetQueueAttributesResult getQueueAttributesResult = sqs.getQueueAttributes(getQueueAttributesRequest);
      attributes = getQueueAttributesResult.getAttributes();
    } catch (Exception ex) {
      logger.error("event_failed_to_get_attributes queue_url=" + queueUrl, ex);
      throw new ServletException(ex);
View Full Code Here

        if (queueUrl != null) {
       
          Map<String, String> attributes = null;
         
          try {
            GetQueueAttributesRequest getQueueAttributesRequest = new GetQueueAttributesRequest(queueUrl);
            getQueueAttributesRequest.setAttributeNames(Arrays.asList("VisibilityTimeout", "MaximumMessageSize", "MessageRetentionPeriod", "DelaySeconds", "ReceiveMessageWaitTimeSeconds", "NumberOfPartitions", "NumberOfShards", "IsCompressed"));
            GetQueueAttributesResult getQueueAttributesResult = sqs.getQueueAttributes(getQueueAttributesRequest);
            attributes = getQueueAttributesResult.getAttributes();
            visibilityTimeout = attributes.get("VisibilityTimeout");
            maximumMessageSize = attributes.get("MaximumMessageSize");
            messageRetentionPeriod = attributes.get("MessageRetentionPeriod");
View Full Code Here

   
    int numberOfShards = 1;
   
    try
     
      GetQueueAttributesRequest getQueueAttributesRequest = new GetQueueAttributesRequest(queueUrl);
      getQueueAttributesRequest.setAttributeNames(Arrays.asList("NumberOfShards"));
      GetQueueAttributesResult getQueueAttributesResult = sqs.getQueueAttributes(getQueueAttributesRequest);
      Map<String, String> attributes = getQueueAttributesResult.getAttributes();
          numberOfShards = Integer.parseInt(attributes.get("NumberOfShards"));
     
    } catch (Exception ex) {
View Full Code Here

      Map<String, String> attributes = new HashMap<String, String>();

      if (showQueueAttributes) {
        try
          GetQueueAttributesRequest getQueueAttributesRequest = new GetQueueAttributesRequest(queueUrls.get(i));
          getQueueAttributesRequest.setAttributeNames(
              Arrays.asList("VisibilityTimeout", "MaximumMessageSize", "MessageRetentionPeriod", "DelaySeconds",
                  "ApproximateNumberOfMessages",
                  "ApproximateNumberOfMessagesNotVisible",
                  "ApproximateNumberOfMessagesDelayed",        
                  "ReceiveMessageWaitTimeSeconds", "NumberOfPartitions", "NumberOfShards", "IsCompressed"));
View Full Code Here

    resolveQueueArn();
  }

  private void resolveQueueArn() {
    GetQueueAttributesRequest request = new GetQueueAttributesRequest(
        queueUrl);
    GetQueueAttributesResult result = sqsClient.getQueueAttributes(request
        .withAttributeNames(Collections.singletonList(QUEUE_ARN_KEY)));
    queueArn = result.getAttributes().get(QUEUE_ARN_KEY);
  }
View Full Code Here

  }

  private void addPermissions() {
    if (permissions != null && permissions.isEmpty() == false) {
      GetQueueAttributesResult result = sqsClient
          .getQueueAttributes(new GetQueueAttributesRequest(queueUrl,
              Arrays.asList("Policy")));

      AwsUtil.addPermissions(result.getAttributes(), permissions,
          new AwsUtil.AddPermissionHandler() {
View Full Code Here

    }

    String publishPolicyKey = String.format("SNS-%s-SQS-%s", topicName,
        queueName);
    String policyId = null;
    GetQueueAttributesRequest getAttrRequest = new GetQueueAttributesRequest(
        queueUrl);
    getAttrRequest.setAttributeNames(Collections.singletonList("Policy"));
    GetQueueAttributesResult result = sqsClient
        .getQueueAttributes(getAttrRequest);
    Map<String, String> attributes = result.getAttributes();
    String policyStr = attributes.get("Policy");
    log.debug("Policy:" + policyStr);
View Full Code Here

TOP

Related Classes of com.amazonaws.services.sqs.model.GetQueueAttributesRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.