88* ** Minimum requirements** -- Python 3.x (or later) and pip
99* ** Download** -- Download the latest preview release or pick it up from pip:
1010```
11- under construction
11+ pip install amazon-sns-extended-client
1212```
1313
1414
@@ -168,7 +168,6 @@ To use custom keys add the S3 key as a Message Attribute in the MessageAttribute
168168
169169** Key - "S3Key"**
170170``` python
171- sns = boto3.client(' sns' )
172171sns.publish(
173172 Message = " message" ,
174173 MessageAttributes = {
@@ -224,7 +223,7 @@ We publish messages to the created Topic and print the published message from th
224223
225224``` python
226225import boto3
227- from src. sns_extended_client import SNSExtendedClientSession
226+ from sns_extended_client import SNSExtendedClientSession
228227from json import loads
229228
230229s3_extended_payload_bucket = " extended-client-bucket-store" # S3 bucket with the given bucket name is a resource which is created and accessible with the given AWS credentials
@@ -246,7 +245,7 @@ def fetch_and_print_from_sqs(sqs, queue_url):
246245 message = sqs.receive_message(
247246 QueueUrl = queue_url, MessageAttributeNames = [" All" ], MaxNumberOfMessages = 1
248247 ).get(" Messages" )[0 ]
249- message_body = loads( message.get(" Body" )).get( " Message " )
248+ message_body = message.get(" Body" )
250249 print (" Published Message: {} " .format(message_body))
251250 print (" Message Stored in S3 Bucket is: {} \n " .format(get_msg_from_s3(message_body)))
252251
@@ -262,11 +261,12 @@ demo_queue_arn = sqs.get_queue_attributes(
262261 QueueUrl = demo_queue_url, AttributeNames = [" QueueArn" ]
263262)[" Attributes" ].get(" QueueArn" )
264263
265- sns_extended_client.subscribe(
266- TopicArn = demo_topic_arn, Protocol = " sqs " , Endpoint = demo_queue_arn
267- )
268-
264+ # Set the RawMessageDelivery subscription attribute to TRUE if you want to use
265+ # SQSExtendedClient to help with retrieving msg from S3
266+ sns_extended_client.subscribe( TopicArn = demo_topic_arn, Protocol = " sqs " ,
267+ Endpoint = demo_queue_arn, Attributes = { " RawMessageDelivery " : " true " })
269268
269+ # Below is the example that all the messages will be sent to the S3 bucket
270270sns_extended_client.large_payload_support = s3_extended_payload_bucket
271271sns_extended_client.always_through_s3 = True
272272sns_extended_client.publish(
@@ -275,6 +275,7 @@ sns_extended_client.publish(
275275print (" \n\n Published using SNS extended client:" )
276276fetch_and_print_from_sqs(sqs, demo_queue_url) # Prints message stored in s3
277277
278+ # Below is the example that all the messages larger than 32 bytes will be sent to the S3 bucket
278279print (" \n Using decreased message size threshold:" )
279280
280281sns_extended_client.always_through_s3 = False
@@ -287,7 +288,7 @@ sns_extended_client.publish(
287288fetch_and_print_from_sqs(sqs, demo_queue_url) # Prints message stored in s3
288289
289290
290- # publish message using the SNS.Topic resource
291+ # Below is the example to publish message using the SNS.Topic resource
291292sns_extended_client_resource = SNSExtendedClientSession().resource(
292293 " sns" , region_name = " us-east-1"
293294)
@@ -326,6 +327,15 @@ Published Message: ["software.amazon.payloadoffloading.PayloadS3Pointer", {"s3Bu
326327Message Stored in S3 Bucket is: This message should be published to S3 using the topic resource
327328```
328329
330+ ## DEVELOPMENT
331+
332+ We have built-in Makefile to run test, format check or fix in one command. Please check [ Makefile] ( Makefile ) for more information.
333+
334+ Just run below command, and it will do format check and run unit test:
335+ ```
336+ make ci
337+ ```
338+
329339## Security
330340
331341See [ CONTRIBUTING] ( CONTRIBUTING.md#security-issue-notifications ) for more information.
0 commit comments