GPrabhudas commented on a change in pull request #560:
URL: https://github.com/apache/pulsar-client-go/pull/560#discussion_r691737883
##########
File path: pulsar/internal/commands.go
##########
@@ -221,9 +222,21 @@ func serializeBatch(wb Buffer,
cmdSend *pb.BaseCommand,
msgMetadata *pb.MessageMetadata,
uncompressedPayload Buffer,
- compressionProvider compression.Provider) {
+ compressionProvider compression.Provider,
+ encryptor crypto.Encryptor) {
// Wire format
// [TOTAL_SIZE] [CMD_SIZE][CMD] [MAGIC_NUMBER][CHECKSUM]
[METADATA_SIZE][METADATA] [PAYLOAD]
+
+ // compress the payload
+ compressedPayload := compressionProvider.Compress(nil,
uncompressedPayload.ReadableSlice())
+
+ // encrypt the compressed payload
+ encryptedPayload, err := encryptor.Encrypt(compressedPayload,
crypto.NewMessageMetadataSupplier(msgMetadata))
+ if err != nil {
+ // error occurred while encrypting the payload,
ProducerCryptoFailureAction is set to Fail
+ panic(fmt.Sprintf("Encryption of message failed,
ProducerCryptoFailureAction is set to Fail. Error :%v", err))
Review comment:
Thanks @jerrypeng @cckellogg Yes, I agree It is better to not crash
the application.
But I'm just trying to understand how java client do not crash the
application.
I found below steps where in it throws exception and possibly crash the
application.
- [ProducerBase
send](https://github.com/apache/pulsar/blob/34a04b5fa4692cb4716df61e740795467f76451b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerBase.java#L63)
- [TypedMessaggeBuilderImpl
send](https://github.com/apache/pulsar/blob/34a04b5fa4692cb4716df61e740795467f76451b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/TypedMessageBuilderImpl.java#L91)
- [ProducerImpl completable
future](https://github.com/apache/pulsar/blob/34a04b5fa4692cb4716df61e740795467f76451b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L466)
- [ProducerImpl completing future with
exception](https://github.com/apache/pulsar/blob/34a04b5fa4692cb4716df61e740795467f76451b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L318)
- [ProducerImpl
encryptMessage](https://github.com/apache/pulsar/blob/34a04b5fa4692cb4716df61e740795467f76451b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L679)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]