Reputation: 137
I am already using Spring Cloud AWS Messaging with SNS and SQS but I now I have a limitation because I am dealing with payloads bigger than 256kb.
I have done some research and I believe the answer to my question is NO but just checking to be sure...
Edit: My concern was how to use payload offloading with Spring AWS Cloud where currently I am using NotificationMessagingTemplate class. For the workaround, I have added the following dependency software.amazon.sns:sns-extended-client:1.0.0 which gave me access to SNSExtendedClientConfiguration and AmazonSNSExcentedeClient classes and I was able to send messages over 256kb doing payload offloading to an S3 bucket. I was also kind of confused with the AWS Java SDK due to springboot is still using version 1.X and an out of support one as far as I understand.
Upvotes: 0
Views: 700
Reputation: 137
I have added the following dependency software.amazon.sns:sns-extended-client:1.0.0 which gave me access to SNSExtendedClientConfiguration and AmazonSNSExtendedClient classes and I was able to send messages over 256kb doing payload offloading to an S3 bucket
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.sns.AmazonSNS;
import com.amazonaws.services.sns.model.PublishRequest;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import software.amazon.sns.AmazonSNSExtendedClient;
import software.amazon.sns.SNSExtendedClientConfiguration;
@Component
public class SnsService {
@Autowired
AmazonSNS snsClient;
@Autowired
ObjectMapper mapper;
@Autowired
AmazonS3 s3Client;
public void sendLargePayloads(String topicName, String bucket, Object message, String subject) {
final SNSExtendedClientConfiguration snsExtendedClientConfiguration = new SNSExtendedClientConfiguration()
.withPayloadSupportEnabled(s3Client, bucket);
final AmazonSNSExtendedClient snsExtendedClient = new AmazonSNSExtendedClient(snsClient,
snsExtendedClientConfiguration);
try {
snsExtendedClient.publish(new PublishRequest().withTopicArn(topicName).withSubject(subject)
.withMessage(mapper.writeValueAsString(message)));
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
}
Upvotes: 0
Reputation: 10734
The max size is 256 as specified in the docs here:
Amazon SQS and SNS Announce 256KB Large Payloads
Upvotes: 0