View Javadoc

1   package com.atlassian.messagequeue.internal.core;
2   
3   import java.util.Collections;
4   import java.util.HashMap;
5   import java.util.Map;
6   
7   /**
8    * A message intended to be nested inside the payload of a SQS message.
9    *
10   * This class represents a deliberate intent to avoid using SQS message attributes. One reason is that some
11   * external services can only produce SQS messages <em>without attributes</em> onto a SQS queue. For
12   * compatibility with those services, AMQ will too eschew attributes.
13   */
14  public class NestedMessage {
15      private Map<String, String> attributes = new HashMap<>();
16      private String payload;
17  
18      public String getAttribute(String name) {
19          return attributes.get(name);
20      }
21  
22      public NestedMessage addAttribute(String name, String value) {
23          attributes.put(name, value);
24          return this;
25      }
26  
27      Map<String, String> getAttributesClone() {
28          return Collections.unmodifiableMap(attributes);
29      }
30  
31      public String getPayload() {
32          return payload;
33      }
34  
35      public NestedMessage setPayload(String payload) {
36          this.payload = payload;
37          return this;
38      }
39  }