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/05/02 17:53:35 UTC

[GitHub] [pulsar] wolfstudy commented on a change in pull request #4093: [issue#4042] improve java functions API

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

 ##########
 File path: pulsar-functions/java-examples/src/main/java/org/apache/pulsar/functions/api/examples/PublishFunctionWithMessageConf.java
 ##########
 @@ -40,13 +41,14 @@ public Void process(String input, Context context) {
         properties.put("input_topic", context.getCurrentRecord().getTopicName().get());
         properties.putAll(context.getCurrentRecord().getProperties());
 
-        Map<String, Object> messageConf = new HashMap<>();
-        messageConf.put(TypedMessageBuilder.CONF_PROPERTIES, properties);
-        if (context.getCurrentRecord().getKey().isPresent()) {
-            messageConf.put(TypedMessageBuilder.CONF_KEY, context.getCurrentRecord().getKey().get());
+        try {
+            TypedMessageBuilder<String> msgBuilder = context.newOutputMessage(publishTopic, null);
+            msgBuilder.value(output).properties(properties).
+                    key(context.getCurrentRecord().getKey().get()).
+                    eventTime(System.currentTimeMillis()).sendAsync();
+        } catch (PulsarClientException e) {
+            e.printStackTrace();
 
 Review comment:
   thanks @jerrypeng remind

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