<sqs><message>{"music":"rock & roll"}</message></sqs>
Note that the ampersand in the message body is properly XML escaped, however, Amazon's own AWS library returns this as the message body once unmarshalled:
{"music":"rock &In other words, the message body ends abruptly at the ampersand, and needless to say, any reasonable JSON library will fail to parse this malformed block of nonsense.
Solution: if you are going to use SQS, and there's a possibility the messages you're going to push onto a queue will have issues with XML escaping, it appears you should always base-64 encode the message body, then base-64 decode it when popping. Fortunately, the Apache Commons Codec library has a wonderful Base64 class to handle this encoding and decoding mess for you.
Bottom line, if you're encountering encoding issues with Amazon's SQS, better check if your messages are able to make it through the XML marshalling and unmarshalling process. If not, you'll need to base-64 encode and decode your messages to dance around bugs in Amazon's AWS library.
Good luck, and hope this helps.


Did you find this post helpful, or at least, interesting?