LrSqsQueueAttributes.attributes

Returns all of the attributes in the collection.

public Map<LrSqsQueueAttributeName, String> attributes()

Return values

This function returns a collection (Map) of queue attributes. Each attribute consists of a name (LrSqsQueueAttributeName object) and a value (String).

Example

Copy code
public int action() throws Throwable {
        LrSqsClient.initClient(region, fifoQueueUrl);
        Map<String, String> initialQueueAttributes = LrSqsClient.getQueueAttributes(new ArrayList()
        {{
              add("ContentBasedDeduplication");
              add("FifoThroughputLimit");
              add("DeduplicationScope");
         }}).attributesAsStrings();
        
        Map<LrSqsQueueAttributeName, String> initialQueueAttributes_ = LrSqsClient.getQueueAttributes(new ArrayList()
        {{
              add("ContentBasedDeduplication");
              add("FifoThroughputLimit");
              add("DeduplicationScope");
         }}).attributes();
        
        boolean contentBasedDeduplication = initialQueueAttributes.get("ContentBasedDeduplication") == "true";
        String fifoThroughputLimit = initialQueueAttributes.get("FifoThroughputLimit");
        String deduplicationScope = initialQueueAttributes.get("DeduplicationScope");
            
        HashMap<String, String> newAttributeValues = new HashMap()
        {{
            put("ContentBasedDeduplication", !contentBasedDeduplication ? "true" : "false");
            put("FifoThroughputLimit", fifoThroughputLimit.equals("perQueue") ? "perMessageGroupId" : "perQueue");
            put("DeduplicationScope", deduplicationScope.equals("messageGroup") ? "queue" : "messageGroup");
        }};    
        LrSqsClient.setQueueAttributes(newAttributeValues);
            
        LrSqsClient.setQueueAttributes(initialQueueAttributes);
        LrSqsClient.closeClient();

        return 0;
    }