Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions memphis/producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ async def validate_msg(self, message):
message = str(msg.loc.source.body)
message = message.encode("utf-8")
return message
elif hasattr(message, "SerializeToString"):
msgToSend = message.SerializeToString()
return msgToSend
elif not isinstance(message, bytearray) and not isinstance(message, dict):
raise MemphisSchemaError("Unsupported message type")
else:
Expand All @@ -78,6 +81,13 @@ def validate_protobuf(self, message):
msgToSend = message.SerializeToString()
proto_msg.ParseFromString(msgToSend)
proto_msg.SerializeToString()
try:
proto_msg.ParseFromString(msgToSend)
proto_msg.SerializeToString()
except Exception as e:
if "parsing message" in str(e):
e = "Error parsing protobuf message"
raise MemphisSchemaError(str(e))
return msgToSend

else:
Expand Down