You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/10/14 16:05:00 UTC

[GitHub] patpatpat123 opened a new issue #297: [Questions] Java based Kafka Producer to trigger OpenWhisk action

patpatpat123 opened a new issue #297: [Questions] Java based Kafka Producer to trigger OpenWhisk action
URL: https://github.com/apache/incubator-openwhisk-package-kafka/issues/297
 
 
   Hello,
   
   I wanted to contribute with a Java based Kafka end to end flow for serverless OpenWhisk.
   
   By that, I mean to take the basic hello world and have a java Kafka based producer on one side, with a Kafka based consumer on the other. (That will mimic real life scenario where micro services call each other, or an OpenWhisk action responding to live Kafka event).
   
   public class Hello {
       public static JsonObject main(JsonObject args) {
           String name = "stranger";
           if (args.has("name"))
               name = args.getAsJsonPrimitive("name").getAsString();
           JsonObject response = new JsonObject();
           response.addProperty("greeting", "Hello " + name + "!");
           return response;
       }
   }
   
   Can it be possible to trigger/invoke this OpenWhisk deployed function with a plain java Producer, like this?
   
   public class Producer {
       public static void main(String[] args) throws Exception{
           Properties kafkaParams = new Properties();
           String topicName = "### mytopic";
           kafkaParams.put("bootstrap.servers", "_some-kafka:9092_");
           [and some other Kafka properties]
           Producer<String, String> producer = new KafkaProducer<>(kafkaParams);
          
                   **producer.send(new ProducerRecord<>(topicName,"somekey", "{\"name\":\"world\"}));**
   
             }
   
   1. First of all, is it something supported? Feasible? 
   If yes (which I really hope!), what is the correct way to deploy the hello world function? Still with wsk -i action create helloJava pof-1.1.jar --main Hello ?
   
   2. If we use a local docker development first, shall we do the docker pull of openwhisk/kafkaprovider? Shall we incorporate it to the docker-compose file of incubator-openwhisk-devtools for the docker run?
   
   3. For Kafka, but with a local docker, shall we start with the package binding?
   wsk package bind /whisk.system/messaging myMessageHub -p kafka_brokers_sasl "[\"_some-kaka:9092_\"]" 
   without user, password and admin?
   
   4. I believe the trigger is the most important step, linking the producer to the java function (OpenWhisk action), is that correct? if yes, shall I run 
   wsk trigger create MyKafkaTrigger -f /whisk.system/messaging/kafkaFeed -p brokers "[\"_some-kafka:9092\", \"some-kafka:9093_\"]" -p topic ### mytopic -p isJSONData true
   
   5. About the kafkaParams, which one shall be altered for OpenWhisk? The key/value serializer can be left with StringSerializer? How about he security protocols?
   
   6. Finally, what will the payload looks like? For example, if the isJSONData is true, shall I send "**{\"name\":\"world\"}**? {"value": "{\"name\":\"world\"}"}? Or the entire message payload with partition, key, offset, topic and value those shall be manually added? Or just to focus on the value of the payload?
   
   
   I hope not to trouble with those questions, as I believe it is an interesting case and usage of OpenWhisk package Kafka and OpenWhisk in general.
   
   Thank you a lot

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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