jerrypeng commented on a change in pull request #4093: [issue#4042] improve 
java functions API
URL: https://github.com/apache/pulsar/pull/4093#discussion_r280524325
 
 

 ##########
 File path: 
pulsar-functions/java-examples/src/main/java/org/apache/pulsar/functions/api/examples/PublishFunction.java
 ##########
 @@ -30,7 +32,12 @@
     public Void process(String input, Context context) {
         String publishTopic = (String) 
context.getUserConfigValueOrDefault("publish-topic", "publishtopic");
         String output = String.format("%s!", input);
-        context.publish(publishTopic, output);
+        try {
+            TypedMessageBuilder<String> msgBuilder = 
context.newOutputMessage(publishTopic, null);
+            msgBuilder.value(output).sendAsync();
+        } catch (PulsarClientException e) {
+            e.printStackTrace();
 
 Review comment:
   @wolfstudy can you replace this with context.getLogger().error(e)

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