Skip to content

Commit

Permalink
Messages larger than 1mb caught.
Browse files Browse the repository at this point in the history
TODO: find a way so that the message is not removed if its larger than 1mb
Signed-off-by: jounaidr <[email protected]>
  • Loading branch information
jounaidr authored and tofu-rocketry committed Jun 12, 2023
1 parent b1aab5c commit 91b65a2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ssm/ssm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from __future__ import print_function

import pkg_resources
from pympler import asizeof

from ssm import crypto
from ssm.message_directory import MessageDirectory
Expand Down Expand Up @@ -390,8 +391,13 @@ def _send_msg_ams(self, text, msgid):
message = AmsMessage(data=to_send,
attributes={'empaid': msgid}).dict()

argo_response = self._ams.publish(self._dest, message, retry=3)
return argo_response['messageIds'][0]
# Check the encrypted and wrapped message is less than 1mb
if asizeof.asizeof(message) < 1048576:
argo_response = self._ams.publish(self._dest, message, retry=3)
return argo_response['messageIds'][0]

else:
log.error('Message %s could not be sent as its larger than 1MB', msgid)

def pull_msg_ams(self):
"""Pull 1 message from the AMS and acknowledge it."""
Expand Down

0 comments on commit 91b65a2

Please sign in to comment.