You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/06/18 01:28:49 UTC

[GitHub] [pulsar] sijie commented on a change in pull request #4534: Support Pulsar schema for pulsar kafka client wrapper

sijie commented on a change in pull request #4534: Support Pulsar schema for pulsar kafka client wrapper
URL: https://github.com/apache/pulsar/pull/4534#discussion_r294578934
 
 

 ##########
 File path: pulsar-client-kafka-compat/pulsar-client-kafka/src/main/java/org/apache/pulsar/client/kafka/compat/KafkaProducerInterceptorWrapper.java
 ##########
 @@ -196,21 +198,24 @@ public void onSendAcknowledgement(Producer<byte[]> producer, Message<byte[]> mes
     }
 
     private String serializeKey(String topic, K key) {
+        PulsarKafkaSchema<K> pulsarKeyKafkaSchema = (PulsarKafkaSchema<K>) keySerializer;
         // If key is a String, we can use it as it is, otherwise, serialize to byte[] and encode in base64
-        if (keySerializer instanceof StringSerializer) {
+        if (pulsarKeyKafkaSchema.getKafkaSerializer() instanceof StringSerializer) {
             return (String) key;
         } else {
-            byte[] keyBytes = keySerializer.serialize(topic, key);
+            pulsarKeyKafkaSchema.setTopic(topic);
+            byte[] keyBytes = keySerializer.encode(key);
             return Base64.getEncoder().encodeToString(keyBytes);
         }
     }
 
     private K deserializeKey(String topic, String key) {
+        PulsarKafkaSchema<K> pulsarKeyKafkaSchema = (PulsarKafkaSchema<K>) keySerializer;
         // If key is a String, we can use it as it is, otherwise, serialize to byte[] and encode in base64
-        if (keySerializer instanceof StringSerializer) {
+        if (pulsarKeyKafkaSchema.getKafkaSerializer() instanceof StringSerializer) {
 
 Review comment:
   change the logic similar as serializeKey

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services