diff --git a/.gitignore b/.gitignore
index 2f7896d..07827cc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
target/
+.idea/
\ No newline at end of file
diff --git a/README.md b/README.md
index 04cf6dd..48b148a 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ for communicating with Amazon Simple Queue Service. This project builds on top o
com.amazonaws
amazon-sqs-java-messaging-lib
- 1.2.0
+ 1.2.1
jar
```
@@ -23,7 +23,7 @@ for communicating with Amazon Simple Queue Service. This project builds on top o
## Feedback
* Give us feedback [here](https://github.com/awslabs/amazon-sqs-java-messaging-lib/issues).
-* If you'd like to contribute a new feature or bug fix, we'd love to see Github pull requests from you.
+* If you'd like to contribute a new feature or bug fix, we'd love to see GitHub pull requests from you.
diff --git a/pom.xml b/pom.xml
index 7724728..4a8fbb3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.amazonaws
amazon-sqs-java-messaging-lib
- 1.2.0
+ 1.2.1
Amazon SQS Java Messaging Library
The Amazon SQS Java Messaging Library holds the Java Message Service compatible classes, that are used
for communicating with Amazon Simple Queue Service.
@@ -29,7 +29,7 @@
- 1.12.415
+ 1.12.778
UTF-8
@@ -47,19 +47,19 @@
org.junit.jupiter
junit-jupiter
- 5.9.2
+ 5.11.3
test
junit
junit
- 4.13.1
+ 4.13.2
test
org.mockito
mockito-core
- 5.1.1
+ 5.14.2
test
diff --git a/src/main/java/com/amazon/sqs/javamessaging/SQSMessagingClientConstants.java b/src/main/java/com/amazon/sqs/javamessaging/SQSMessagingClientConstants.java
index 21ccdfb..011c122 100644
--- a/src/main/java/com/amazon/sqs/javamessaging/SQSMessagingClientConstants.java
+++ b/src/main/java/com/amazon/sqs/javamessaging/SQSMessagingClientConstants.java
@@ -51,6 +51,8 @@ public class SQSMessagingClientConstants {
public static final String SHORT = "Number.short";
+ public static final String BINARY = "Binary";
+
public static final String INT_FALSE = "0";
public static final String INT_TRUE = "1";
diff --git a/src/main/java/com/amazon/sqs/javamessaging/message/SQSMessage.java b/src/main/java/com/amazon/sqs/javamessaging/message/SQSMessage.java
index a5f4965..17d53f2 100644
--- a/src/main/java/com/amazon/sqs/javamessaging/message/SQSMessage.java
+++ b/src/main/java/com/amazon/sqs/javamessaging/message/SQSMessage.java
@@ -35,6 +35,8 @@
import com.amazon.sqs.javamessaging.SQSQueueDestination;
import com.amazon.sqs.javamessaging.acknowledge.Acknowledger;
import com.amazonaws.services.sqs.model.MessageAttributeValue;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import static com.amazon.sqs.javamessaging.SQSMessagingClientConstants.*;
@@ -60,7 +62,8 @@
* approximate Receive Count observed on the SQS side.
*/
public class SQSMessage implements Message {
-
+
+ private static final Log LOG = LogFactory.getLog(SQSMessage.class);
private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
// Define constant message types.
@@ -1150,9 +1153,11 @@ private static Object getObjectValue(String value, String type) throws JMSExcept
return Float.valueOf(value);
} else if (SHORT.equals(type)) {
return Short.valueOf(value);
- } else if (type != null && (type.startsWith(STRING) || type.startsWith(NUMBER))) {
+ } else if (type != null && (type.startsWith(STRING) || type.startsWith(NUMBER) || type.startsWith(BINARY))) {
return value;
} else {
+ LOG.debug("Caught exception while constructing message attribute. " +
+ "Unknown or yet supported JMS property type - " + type);
throw new JMSException(type + " is not a supported JMS property type");
}
}
diff --git a/src/test/java/com/amazon/sqs/javamessaging/message/SQSMessageTest.java b/src/test/java/com/amazon/sqs/javamessaging/message/SQSMessageTest.java
index 6eb9a78..301e91f 100644
--- a/src/test/java/com/amazon/sqs/javamessaging/message/SQSMessageTest.java
+++ b/src/test/java/com/amazon/sqs/javamessaging/message/SQSMessageTest.java
@@ -25,6 +25,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
@@ -33,6 +35,7 @@
import java.util.Set;
import static com.amazon.sqs.javamessaging.SQSMessagingClientConstants.APPROXIMATE_RECEIVE_COUNT;
+import static com.amazon.sqs.javamessaging.SQSMessagingClientConstants.BINARY;
import static com.amazon.sqs.javamessaging.SQSMessagingClientConstants.JMSX_DELIVERY_COUNT;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -59,6 +62,8 @@ public class SQSMessageTest {
final String myString = "myString";
final String myCustomString = "myCustomString";
final String myNumber = "myNumber";
+ final String myBinary = "myBinary";
+ final String myCustomBinary = "myCustomBinary";
@BeforeEach
public void setup() {
@@ -296,6 +301,18 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
.withDataType(SQSMessagingClientConstants.NUMBER)
.withStringValue("500"));
+ messageAttributes.put(myBinary, new MessageAttributeValue()
+ .withDataType(SQSMessagingClientConstants.BINARY)
+ .withStringValue("BQUZTR1ZzYkc4PQ=="));
+
+ messageAttributes.put(myCustomBinary, new MessageAttributeValue()
+ .withDataType(SQSMessagingClientConstants.BINARY + ".custom")
+ .withStringValue("data:image/gif;base64,QABAAACAkQBADs=")
+ .withBinaryValue(ByteBuffer.wrap("data:image/gif;base64,QABAAACAkQBADs="
+ .getBytes(StandardCharsets.UTF_8))
+ )
+ );
+
com.amazonaws.services.sqs.model.Message sqsMessage = new com.amazonaws.services.sqs.model.Message()
.withMessageAttributes(messageAttributes)
.withAttributes(systemAttributes)
@@ -353,6 +370,12 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
assertEquals(message.getFloatProperty(myNumber), 500f);
assertEquals(message.getDoubleProperty(myNumber), 500d);
+ assertTrue(message.propertyExists(myBinary));
+ assertEquals(message.getObjectProperty(myBinary), "BQUZTR1ZzYkc4PQ==");
+ assertEquals(message.getStringProperty(myBinary), "BQUZTR1ZzYkc4PQ==");
+ assertTrue(message.propertyExists(myCustomBinary));
+ assertEquals(message.getObjectProperty(myCustomBinary), "data:image/gif;base64,QABAAACAkQBADs=");
+ assertEquals(message.getStringProperty(myCustomBinary), "data:image/gif;base64,QABAAACAkQBADs=");
// Validate property names
Set propertyNamesSet = Set.of(
@@ -367,6 +390,8 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
myString,
myCustomString,
myNumber,
+ myBinary,
+ myCustomBinary,
JMSX_DELIVERY_COUNT
);
@@ -388,6 +413,8 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
assertFalse(message.propertyExists("myByteProperty"));
assertFalse(message.propertyExists("myString"));
assertFalse(message.propertyExists("myNumber"));
+ assertFalse(message.propertyExists("myBinary"));
+ assertFalse(message.propertyExists("myCustomBinary"));
propertyNames = message.getPropertyNames();
assertFalse(propertyNames.hasMoreElements());