I am new to AWS.I am trying to attach an object to AWS SQS Message (software.amazon.awssdk.services.sqs.model.Message)
AWS Documentation on the matter is outdated
(https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-java-send-message-with-attributes.html)
(does not compile as written for a previous version. It is easily fixed to be compilable, but is not very useful)
There are many ways to attach a String, but to attach an object the only way seems to be
1 putting the SourceObject into an "SdkBytes"
2 making a Collection of triples (Map<String,MessagAttributes>) to define the name, dataType, and "SdkBytes"
3 feed this Collection into a builder
It seems to me this is the process:
SourceObject -> some InputStreamer -> "SdkBytes" object -> MessageAttributes Object -> AttributesMap <String,MessageAttributes> -> Message.builder().attributes()
Can anyone point me towards a cleaner / better solution? I expect something should exist that looks like:Message.Builder().MessageBody(JsonObject j).build();
Or Message.Builder().MessageBody(File f).build();