mattisonchao commented on code in PR #20958:
URL: https://github.com/apache/pulsar/pull/20958#discussion_r1304038258


##########
pulsar-websocket/src/main/java/org/apache/pulsar/websocket/ProducerHandler.java:
##########
@@ -192,6 +207,27 @@ public void onWebSocketText(String message) {
             builder.deliverAfter(sendRequest.deliverAfterMs, 
TimeUnit.MILLISECONDS);
         }
 
+        // If client-side encryption is enabled, the attributes 
"encryptParam", "uncompressedMessageSize",
+        // "uncompressedMessageSize" and "batchSize" of message metadata must 
be set according to the parameters
+        // when the client sends messages.
+        if (clientSideEncrypt) {
+            try {
+                if (!StringUtils.isBlank(sendRequest.encryptionParam)) {
+                    
builder.getMetadataBuilder().setEncryptionParam(Base64.getDecoder()
+                            .decode(sendRequest.encryptionParam));
+                }
+            } catch (Exception e){
+                String msg = format("Invalid Base64 encryptionParam error=%s", 
e.getMessage());
+                sendAckResponse(new ProducerAck(PayloadEncodingError, msg, 
null, requestContext));
+                return;
+            }
+            if (sendRequest.compressionType != null && 
sendRequest.uncompressedMessageSize != null) {
+                // Set compression information.
+                
builder.getMetadataBuilder().setCompression(sendRequest.compressionType);
+                
builder.getMetadataBuilder().setUncompressedSize(sendRequest.uncompressedMessageSize);

Review Comment:
   Should we clarify this behaviour?  or add some checks?
   - If the user sets `compressionType` without `unCompressedSize` the data 
will auto compressed by the broker.
   - How about the user only set uncompressed size but not set compression type?



-- 
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]

Reply via email to