0
# Queue Tagging
1
2
Queue tagging enables cost allocation tracking, resource organization, and management through key-value metadata tags applied to SQS queues.
3
4
## Tag Queue
5
6
### Add Tags to Queue
7
8
Apply cost allocation and organizational tags to a queue.
9
10
```java { .api }
11
TagQueueResult tagQueue(TagQueueRequest request);
12
13
// Convenience method
14
TagQueueResult tagQueue(String queueUrl, Map<String, String> tags);
15
16
class TagQueueRequest extends AmazonWebServiceRequest {
17
String getQueueUrl();
18
TagQueueRequest withQueueUrl(String queueUrl);
19
20
Map<String, String> getTags();
21
TagQueueRequest withTags(Map<String, String> tags);
22
TagQueueRequest addTagsEntry(String key, String value);
23
}
24
25
class TagQueueResult {
26
// Empty result class - success indicated by no exception
27
}
28
```
29
30
## List Queue Tags
31
32
### Retrieve Queue Tags
33
34
Get all tags currently applied to a queue.
35
36
```java { .api }
37
ListQueueTagsResult listQueueTags(ListQueueTagsRequest request);
38
39
// Convenience method
40
ListQueueTagsResult listQueueTags(String queueUrl);
41
42
class ListQueueTagsRequest extends AmazonWebServiceRequest {
43
String getQueueUrl();
44
ListQueueTagsRequest withQueueUrl(String queueUrl);
45
}
46
47
class ListQueueTagsResult {
48
Map<String, String> getTags();
49
}
50
```
51
52
## Untag Queue
53
54
### Remove Tags from Queue
55
56
Remove specific tags from a queue by tag key.
57
58
```java { .api }
59
UntagQueueResult untagQueue(UntagQueueRequest request);
60
61
// Convenience method
62
UntagQueueResult untagQueue(String queueUrl, List<String> tagKeys);
63
64
class UntagQueueRequest extends AmazonWebServiceRequest {
65
String getQueueUrl();
66
UntagQueueRequest withQueueUrl(String queueUrl);
67
68
List<String> getTagKeys();
69
UntagQueueRequest withTagKeys(List<String> tagKeys);
70
}
71
72
class UntagQueueResult {
73
// Empty result class - success indicated by no exception
74
}
75
```
76
77
**Usage Example:**
78
79
```java
80
// Add tags
81
Map<String, String> tags = new HashMap<>();
82
tags.put("Environment", "Production");
83
tags.put("Team", "Backend");
84
tags.put("CostCenter", "Engineering");
85
86
client.tagQueue(new TagQueueRequest()
87
.withQueueUrl(queueUrl)
88
.withTags(tags));
89
90
// List tags
91
ListQueueTagsResult result = client.listQueueTags(queueUrl);
92
System.out.println("Queue tags: " + result.getTags());
93
94
// Remove specific tags
95
client.untagQueue(new UntagQueueRequest()
96
.withQueueUrl(queueUrl)
97
.withTagKeys(Arrays.asList("CostCenter")));
98
```