congbobo184 commented on a change in pull request #5165: [PIP-43] Support producer to send msg with different schema URL: https://github.com/apache/pulsar/pull/5165#discussion_r323584606
########## File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java ########## @@ -430,6 +438,95 @@ public void sendAsync(Message<T> message, SendCallback callback) { } } + private boolean fillMessageSchema(MessageMetadata.Builder msgMetadataBuilder, + Schema msgSchema, + SendCallback callback) { + if (msgSchema == schema) { + schemaVersion.ifPresent(v -> msgMetadataBuilder.setSchemaVersion(ByteString.copyFrom(v))); + return true; + } + byte[] schemaVersion; + try { + schemaVersion = schemaCache.computeIfAbsent( + SchemaHash.of(msgSchema), (hash) -> { + SchemaInfo schemaInfo = Optional.ofNullable(msgSchema) + .map(Schema::getSchemaInfo) + .filter(si -> si.getType().getValue() > 0) + .orElse(Schema.BYTES.getSchemaInfo()); + try { + return getOrCreateSchemaAsync(schemaInfo).get(); + } catch (Throwable t) { + log.warn("[{}][{}] GetOrCreateSchema error", topic, producerName, t); + callback.sendComplete(PulsarClientException.unwrap(t)); + throw new RuntimeException(t); + } + }); + } catch (RuntimeException e) { + return false; + } + conf.setMultiSchemaEnabled(true); Review comment: I just started to misunderstand this variable. It looks more perfect now. :) ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services