{"action":"created","comment":{"url":"https://api.github.com/repos/confluentinc/examples/pulls/comments/240593962","pull_request_review_id":183655589,"id":240593962,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MDU5Mzk2Mg==","diff_hunk":"@@ -0,0 +1,122 @@\n+/**\n+ * Copyright 2015 Confluent Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package io.confluent.examples.clients.cloud;\n+\n+import org.apache.kafka.clients.producer.KafkaProducer;\n+import org.apache.kafka.clients.producer.ProducerRecord;\n+import org.apache.kafka.clients.producer.RecordMetadata;\n+import org.apache.kafka.clients.producer.Callback;\n+import org.apache.kafka.clients.producer.ProducerConfig;\n+import org.apache.kafka.clients.producer.Producer;\n+import org.apache.kafka.connect.json.JsonSerializer;\n+\n+import org.apache.kafka.clients.admin.AdminClient;\n+import org.apache.kafka.clients.admin.AdminClientConfig;\n+import org.apache.kafka.clients.admin.NewTopic;\n+\n+import io.confluent.examples.clients.cloud.model.RecordJSON;\n+import com.fasterxml.jackson.databind.JsonNode;\n+import com.fasterxml.jackson.databind.ObjectMapper;\n+\n+import java.io.FileInputStream;\n+import java.io.IOException;\n+import java.util.concurrent.ExecutionException;\n+import org.apache.kafka.common.errors.TopicExistsException;\n+import java.io.InputStream;\n+import java.nio.file.Files;\n+import java.nio.file.Paths;\n+import java.util.Properties;\n+import java.util.Collections;\n+import java.util.Map;\n+\n+public class ProducerExample {\n+\n+  private static final ObjectMapper MAPPER = new ObjectMapper();\n+\n+  // Create topic in Confluent Cloud\n+  public static void createTopic(final String topic,\n+                          final int partitions,\n+                          final int replication,\n+                          final Properties cloudConfig) {\n+      final NewTopic newTopic = new NewTopic(topic, partitions, (short) replication);\n+      try (final AdminClient adminClient = AdminClient.create(cloudConfig)) {\n+          adminClient.createTopics(Collections.singletonList(newTopic)).all().get();\n+      } catch (final InterruptedException | ExecutionException e) {\n+          // Ignore if TopicExistsException, which may be valid if topic exists\n+          if (!(e.getCause() instanceof TopicExistsException)) {\n+              throw new RuntimeException(e);\n+          }\n+      }\n+  }\n+\n+  public static void main(String[] args) throws IOException {\n+    if (args.length != 2) {\n+      System.out.println(\"Please provide command line arguments: configPath topic\");\n+      System.exit(-1);\n+    }\n+\n+    // Load properties from file\n+    Properties props = loadConfig(args[0]);\n+\n+    // Create topic if needed\n+    String topic = args[1];\n+    createTopic(topic, 1, 3, props);\n+\n+    // Add additional properties.\n+    props.put(ProducerConfig.ACKS_CONFIG, \"all\");\n+    props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.StringSerializer\");\n+    props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, \"org.apache.kafka.connect.json.JsonSerializer\");\n+\n+    Producer<String, JsonNode> producer = new KafkaProducer<String, JsonNode>(props);\n+\n+    // Produce sample data\n+    final Long numMessages = 10L;\n+    for (Long i = 0L; i < numMessages; i++) {\n+      String key = \"alice\";\n+      RecordJSON countRecord = new RecordJSON(i);\n+      JsonNode value = MAPPER.valueToTree(countRecord);\n+\n+      producer.send(new ProducerRecord<String, JsonNode>(topic, key, value), new Callback() {\n+          @Override\n+          public void onCompletion(RecordMetadata m, Exception e) {\n+            if (e != null) {\n+              e.printStackTrace();\n+            } else {\n+              System.out.printf(\"Produced record to topic %s partition [%d] @ offset %d%n\", m.topic(), m.partition(), m.offset());\n+            }\n+          }\n+      });\n+    }\n+\n+    producer.flush();\n+\n+    System.out.printf(\"10 messages were successfully produced to topic %s%n\", topic);","path":"clients/cloud/java/src/main/java/io/confluent/examples/clients/cloud/ProducerExample.java","position":106,"original_position":106,"commit_id":"f54581e8b688cbefaac88184819294b42a515156","original_commit_id":"f54581e8b688cbefaac88184819294b42a515156","user":{"login":"edenhill","id":524990,"node_id":"MDQ6VXNlcjUyNDk5MA==","avatar_url":"https://avatars0.githubusercontent.com/u/524990?v=4","gravatar_id":"","url":"https://api.github.com/users/edenhill","html_url":"https://github.com/edenhill","followers_url":"https://api.github.com/users/edenhill/followers","following_url":"https://api.github.com/users/edenhill/following{/other_user}","gists_url":"https://api.github.com/users/edenhill/gists{/gist_id}","starred_url":"https://api.github.com/users/edenhill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edenhill/subscriptions","organizations_url":"https://api.github.com/users/edenhill/orgs","repos_url":"https://api.github.com/users/edenhill/repos","events_url":"https://api.github.com/users/edenhill/events{/privacy}","received_events_url":"https://api.github.com/users/edenhill/received_events","type":"User","site_admin":false},"body":"You're asking me to be consistent in my reviews?!\r\n\r\nAll we need to do is remove \"successfully\" for this printout to be true, regardless of delivery status.","created_at":"2018-12-11T12:42:36Z","updated_at":"2018-12-11T12:42:36Z","html_url":"https://github.com/confluentinc/examples/pull/78#discussion_r240593962","pull_request_url":"https://api.github.com/repos/confluentinc/examples/pulls/78","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/confluentinc/examples/pulls/comments/240593962"},"html":{"href":"https://github.com/confluentinc/examples/pull/78#discussion_r240593962"},"pull_request":{"href":"https://api.github.com/repos/confluentinc/examples/pulls/78"}},"in_reply_to_id":240560615},"pull_request":{"url":"https://api.github.com/repos/confluentinc/examples/pulls/78","id":237166531,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM3MTY2NTMx","html_url":"https://github.com/confluentinc/examples/pull/78","diff_url":"https://github.com/confluentinc/examples/pull/78.diff","patch_url":"https://github.com/confluentinc/examples/pull/78.patch","issue_url":"https://api.github.com/repos/confluentinc/examples/issues/78","number":78,"state":"open","locked":false,"title":"DEVX-555, DEVX-547: Make Java producer/consumer & Kafka Streams examples to Confluent Cloud","user":{"login":"ybyzek","id":12448600,"node_id":"MDQ6VXNlcjEyNDQ4NjAw","avatar_url":"https://avatars3.githubusercontent.com/u/12448600?v=4","gravatar_id":"","url":"https://api.github.com/users/ybyzek","html_url":"https://github.com/ybyzek","followers_url":"https://api.github.com/users/ybyzek/followers","following_url":"https://api.github.com/users/ybyzek/following{/other_user}","gists_url":"https://api.github.com/users/ybyzek/gists{/gist_id}","starred_url":"https://api.github.com/users/ybyzek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ybyzek/subscriptions","organizations_url":"https://api.github.com/users/ybyzek/orgs","repos_url":"https://api.github.com/users/ybyzek/repos","events_url":"https://api.github.com/users/ybyzek/events{/privacy}","received_events_url":"https://api.github.com/users/ybyzek/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-12-09T23:47:16Z","updated_at":"2018-12-11T12:42:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7d19725600788dac89d50214d2e52f04ba63d33d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[{"name":"streams","id":2063464,"node_id":"MDQ6VGVhbTIwNjM0NjQ=","slug":"streams","description":"Kafka Streams","privacy":"closed","url":"https://api.github.com/teams/2063464","members_url":"https://api.github.com/teams/2063464/members{/member}","repositories_url":"https://api.github.com/teams/2063464/repos","permission":"pull"},{"name":"core","id":2080251,"node_id":"MDQ6VGVhbTIwODAyNTE=","slug":"core","description":"","privacy":"closed","url":"https://api.github.com/teams/2080251","members_url":"https://api.github.com/teams/2080251/members{/member}","repositories_url":"https://api.github.com/teams/2080251/repos","permission":"pull"}],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/confluentinc/examples/pulls/78/commits","review_comments_url":"https://api.github.com/repos/confluentinc/examples/pulls/78/comments","review_comment_url":"https://api.github.com/repos/confluentinc/examples/pulls/comments{/number}","comments_url":"https://api.github.com/repos/confluentinc/examples/issues/78/comments","statuses_url":"https://api.github.com/repos/confluentinc/examples/statuses/f54581e8b688cbefaac88184819294b42a515156","head":{"label":"confluentinc:DEVX-555","ref":"DEVX-555","sha":"f54581e8b688cbefaac88184819294b42a515156","user":{"login":"confluentinc","id":9439498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0Mzk0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/9439498?v=4","gravatar_id":"","url":"https://api.github.com/users/confluentinc","html_url":"https://github.com/confluentinc","followers_url":"https://api.github.com/users/confluentinc/followers","following_url":"https://api.github.com/users/confluentinc/following{/other_user}","gists_url":"https://api.github.com/users/confluentinc/gists{/gist_id}","starred_url":"https://api.github.com/users/confluentinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/confluentinc/subscriptions","organizations_url":"https://api.github.com/users/confluentinc/orgs","repos_url":"https://api.github.com/users/confluentinc/repos","events_url":"https://api.github.com/users/confluentinc/events{/privacy}","received_events_url":"https://api.github.com/users/confluentinc/received_events","type":"Organization","site_admin":false},"repo":{"id":129901811,"node_id":"MDEwOlJlcG9zaXRvcnkxMjk5MDE4MTE=","name":"examples","full_name":"confluentinc/examples","private":false,"owner":{"login":"confluentinc","id":9439498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0Mzk0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/9439498?v=4","gravatar_id":"","url":"https://api.github.com/users/confluentinc","html_url":"https://github.com/confluentinc","followers_url":"https://api.github.com/users/confluentinc/followers","following_url":"https://api.github.com/users/confluentinc/following{/other_user}","gists_url":"https://api.github.com/users/confluentinc/gists{/gist_id}","starred_url":"https://api.github.com/users/confluentinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/confluentinc/subscriptions","organizations_url":"https://api.github.com/users/confluentinc/orgs","repos_url":"https://api.github.com/users/confluentinc/repos","events_url":"https://api.github.com/users/confluentinc/events{/privacy}","received_events_url":"https://api.github.com/users/confluentinc/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/confluentinc/examples","description":"Apache Kafka and Confluent Platform examples and demos","fork":false,"url":"https://api.github.com/repos/confluentinc/examples","forks_url":"https://api.github.com/repos/confluentinc/examples/forks","keys_url":"https://api.github.com/repos/confluentinc/examples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/confluentinc/examples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/confluentinc/examples/teams","hooks_url":"https://api.github.com/repos/confluentinc/examples/hooks","issue_events_url":"https://api.github.com/repos/confluentinc/examples/issues/events{/number}","events_url":"https://api.github.com/repos/confluentinc/examples/events","assignees_url":"https://api.github.com/repos/confluentinc/examples/assignees{/user}","branches_url":"https://api.github.com/repos/confluentinc/examples/branches{/branch}","tags_url":"https://api.github.com/repos/confluentinc/examples/tags","blobs_url":"https://api.github.com/repos/confluentinc/examples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/confluentinc/examples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/confluentinc/examples/git/refs{/sha}","trees_url":"https://api.github.com/repos/confluentinc/examples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/confluentinc/examples/statuses/{sha}","languages_url":"https://api.github.com/repos/confluentinc/examples/languages","stargazers_url":"https://api.github.com/repos/confluentinc/examples/stargazers","contributors_url":"https://api.github.com/repos/confluentinc/examples/contributors","subscribers_url":"https://api.github.com/repos/confluentinc/examples/subscribers","subscription_url":"https://api.github.com/repos/confluentinc/examples/subscription","commits_url":"https://api.github.com/repos/confluentinc/examples/commits{/sha}","git_commits_url":"https://api.github.com/repos/confluentinc/examples/git/commits{/sha}","comments_url":"https://api.github.com/repos/confluentinc/examples/comments{/number}","issue_comment_url":"https://api.github.com/repos/confluentinc/examples/issues/comments{/number}","contents_url":"https://api.github.com/repos/confluentinc/examples/contents/{+path}","compare_url":"https://api.github.com/repos/confluentinc/examples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/confluentinc/examples/merges","archive_url":"https://api.github.com/repos/confluentinc/examples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/confluentinc/examples/downloads","issues_url":"https://api.github.com/repos/confluentinc/examples/issues{/number}","pulls_url":"https://api.github.com/repos/confluentinc/examples/pulls{/number}","milestones_url":"https://api.github.com/repos/confluentinc/examples/milestones{/number}","notifications_url":"https://api.github.com/repos/confluentinc/examples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/confluentinc/examples/labels{/name}","releases_url":"https://api.github.com/repos/confluentinc/examples/releases{/id}","deployments_url":"https://api.github.com/repos/confluentinc/examples/deployments","created_at":"2018-04-17T12:33:58Z","updated_at":"2018-12-11T01:06:12Z","pushed_at":"2018-12-11T11:45:08Z","git_url":"git://github.com/confluentinc/examples.git","ssh_url":"git@github.com:confluentinc/examples.git","clone_url":"https://github.com/confluentinc/examples.git","svn_url":"https://github.com/confluentinc/examples","homepage":"","size":20336,"stargazers_count":72,"watchers_count":72,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":34,"open_issues":11,"watchers":72,"default_branch":"5.0.1-post"}},"base":{"label":"confluentinc:5.0.1-post","ref":"5.0.1-post","sha":"78ddabc289f81a3abba75176b221a5a6f696144d","user":{"login":"confluentinc","id":9439498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0Mzk0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/9439498?v=4","gravatar_id":"","url":"https://api.github.com/users/confluentinc","html_url":"https://github.com/confluentinc","followers_url":"https://api.github.com/users/confluentinc/followers","following_url":"https://api.github.com/users/confluentinc/following{/other_user}","gists_url":"https://api.github.com/users/confluentinc/gists{/gist_id}","starred_url":"https://api.github.com/users/confluentinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/confluentinc/subscriptions","organizations_url":"https://api.github.com/users/confluentinc/orgs","repos_url":"https://api.github.com/users/confluentinc/repos","events_url":"https://api.github.com/users/confluentinc/events{/privacy}","received_events_url":"https://api.github.com/users/confluentinc/received_events","type":"Organization","site_admin":false},"repo":{"id":129901811,"node_id":"MDEwOlJlcG9zaXRvcnkxMjk5MDE4MTE=","name":"examples","full_name":"confluentinc/examples","private":false,"owner":{"login":"confluentinc","id":9439498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0Mzk0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/9439498?v=4","gravatar_id":"","url":"https://api.github.com/users/confluentinc","html_url":"https://github.com/confluentinc","followers_url":"https://api.github.com/users/confluentinc/followers","following_url":"https://api.github.com/users/confluentinc/following{/other_user}","gists_url":"https://api.github.com/users/confluentinc/gists{/gist_id}","starred_url":"https://api.github.com/users/confluentinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/confluentinc/subscriptions","organizations_url":"https://api.github.com/users/confluentinc/orgs","repos_url":"https://api.github.com/users/confluentinc/repos","events_url":"https://api.github.com/users/confluentinc/events{/privacy}","received_events_url":"https://api.github.com/users/confluentinc/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/confluentinc/examples","description":"Apache Kafka and Confluent Platform examples and demos","fork":false,"url":"https://api.github.com/repos/confluentinc/examples","forks_url":"https://api.github.com/repos/confluentinc/examples/forks","keys_url":"https://api.github.com/repos/confluentinc/examples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/confluentinc/examples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/confluentinc/examples/teams","hooks_url":"https://api.github.com/repos/confluentinc/examples/hooks","issue_events_url":"https://api.github.com/repos/confluentinc/examples/issues/events{/number}","events_url":"https://api.github.com/repos/confluentinc/examples/events","assignees_url":"https://api.github.com/repos/confluentinc/examples/assignees{/user}","branches_url":"https://api.github.com/repos/confluentinc/examples/branches{/branch}","tags_url":"https://api.github.com/repos/confluentinc/examples/tags","blobs_url":"https://api.github.com/repos/confluentinc/examples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/confluentinc/examples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/confluentinc/examples/git/refs{/sha}","trees_url":"https://api.github.com/repos/confluentinc/examples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/confluentinc/examples/statuses/{sha}","languages_url":"https://api.github.com/repos/confluentinc/examples/languages","stargazers_url":"https://api.github.com/repos/confluentinc/examples/stargazers","contributors_url":"https://api.github.com/repos/confluentinc/examples/contributors","subscribers_url":"https://api.github.com/repos/confluentinc/examples/subscribers","subscription_url":"https://api.github.com/repos/confluentinc/examples/subscription","commits_url":"https://api.github.com/repos/confluentinc/examples/commits{/sha}","git_commits_url":"https://api.github.com/repos/confluentinc/examples/git/commits{/sha}","comments_url":"https://api.github.com/repos/confluentinc/examples/comments{/number}","issue_comment_url":"https://api.github.com/repos/confluentinc/examples/issues/comments{/number}","contents_url":"https://api.github.com/repos/confluentinc/examples/contents/{+path}","compare_url":"https://api.github.com/repos/confluentinc/examples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/confluentinc/examples/merges","archive_url":"https://api.github.com/repos/confluentinc/examples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/confluentinc/examples/downloads","issues_url":"https://api.github.com/repos/confluentinc/examples/issues{/number}","pulls_url":"https://api.github.com/repos/confluentinc/examples/pulls{/number}","milestones_url":"https://api.github.com/repos/confluentinc/examples/milestones{/number}","notifications_url":"https://api.github.com/repos/confluentinc/examples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/confluentinc/examples/labels{/name}","releases_url":"https://api.github.com/repos/confluentinc/examples/releases{/id}","deployments_url":"https://api.github.com/repos/confluentinc/examples/deployments","created_at":"2018-04-17T12:33:58Z","updated_at":"2018-12-11T01:06:12Z","pushed_at":"2018-12-11T11:45:08Z","git_url":"git://github.com/confluentinc/examples.git","ssh_url":"git@github.com:confluentinc/examples.git","clone_url":"https://github.com/confluentinc/examples.git","svn_url":"https://github.com/confluentinc/examples","homepage":"","size":20336,"stargazers_count":72,"watchers_count":72,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":34,"open_issues":11,"watchers":72,"default_branch":"5.0.1-post"}},"_links":{"self":{"href":"https://api.github.com/repos/confluentinc/examples/pulls/78"},"html":{"href":"https://github.com/confluentinc/examples/pull/78"},"issue":{"href":"https://api.github.com/repos/confluentinc/examples/issues/78"},"comments":{"href":"https://api.github.com/repos/confluentinc/examples/issues/78/comments"},"review_comments":{"href":"https://api.github.com/repos/confluentinc/examples/pulls/78/comments"},"review_comment":{"href":"https://api.github.com/repos/confluentinc/examples/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/confluentinc/examples/pulls/78/commits"},"statuses":{"href":"https://api.github.com/repos/confluentinc/examples/statuses/f54581e8b688cbefaac88184819294b42a515156"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"edenhill"}}