sijie commented on issue #4093: [issue#4042] improve java functions API
URL: https://github.com/apache/pulsar/pull/4093#issuecomment-485079116
 
 
   I strongly believe newOutputMessage is the right approach for deprecating 
context.publish. All context.publish methods should be deprecated and they 
should be changed to use the newOutputMessage. 
   
   Jerry, if you check the code, the current context.publish really does 
nothing than just wrapping the newMessageBuilder. Move the message builder to 
the interface is actually making a lot of things clearer and reduce the 
complexity on maintaining various overridden methods. 
   
   TypedMessageBuilder<O> messageBuilder = producer.newMessage();
           if (messageConf != null) {
               messageBuilder.loadConf(messageConf);
           }
           CompletableFuture<Void> future = 
messageBuilder.value(object).sendAsync().thenApply(msgId -> null);
           future.exceptionally(e -> {
               this.statsManager.incrSysExceptions(e);
               logger.error("Failed to publish to topic {} with error {}", 
topicName, e);
               return null;
           });
           return future;

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to