You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/04/08 00:08:29 UTC

[GitHub] [pulsar-adapters] dlg99 opened a new pull request #10: Feature: Run Kafka streams app with Pulsar

dlg99 opened a new pull request #10:
URL: https://github.com/apache/pulsar-adapters/pull/10


   <!--
   ### Contribution Checklist
     
     - Name the pull request in the form "[Issue XYZ][component] Title of the pull request", where *XYZ* should be replaced by the actual issue number.
       Skip *Issue XYZ* if there is no associated github issue for this pull request.
       Skip *component* if you are unsure about which is the best component. E.g. `[docs] Fix typo in produce method`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ### Motivation
   
   Provide an easy way to run Kafka Streams applications with Pulsar.
   Depends on https://github.com/apache/pulsar-adapters/pull/9
   
   ### Modifications
   
   Upgraded to Kafka client 2.7
   Fixed Consumer and Producer logic that was not enough for KafkaStreams to run.
   Added/shaded noop AdminClient to prevent Stream from trying to use kafka's one.
   
   ### Verifying this change
   
   Added example and description on how to run it.
   
   Integration tests do not pass (even without the changes), did not try to add the new one.
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): yes
   
   ### Documentation
   
     - Does this pull request introduce a new feature? kind of
     - If yes, how is the feature documented? Readme, example, comments.
   


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



[GitHub] [pulsar-adapters] eolivelli commented on a change in pull request #10: Feature: Run Kafka streams app with Pulsar

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #10:
URL: https://github.com/apache/pulsar-adapters/pull/10#discussion_r611009051



##########
File path: pulsar-client-kafka-compat/pulsar-client-kafka/src/main/java/org/apache/kafka/clients/producer/PulsarKafkaProducer.java
##########
@@ -366,7 +372,15 @@ private RecordMetadata getRecordMetadata(String topic, TypedMessageBuilder<byte[
 
         TopicPartition tp = new TopicPartition(topic, partition);
         TypedMessageBuilderImpl<byte[]> mb = (TypedMessageBuilderImpl<byte[]>) msgBuilder;
-        return new RecordMetadata(tp, offset, 0L, mb.getPublishTime(), 0L, mb.hasKey() ? mb.getKey().length() : 0, size);
+
+        long publishTime = 0L;
+        try {
+            // there is no hasPublishTime() currently
+            publishTime = mb.getPublishTime();
+        } catch (IllegalStateException ise) {
+            logger.debug("could not get publish time");

Review comment:
       @dlg99 good point. +1




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



[GitHub] [pulsar-adapters] dlg99 edited a comment on pull request #10: Feature: Run Kafka streams app with Pulsar

Posted by GitBox <gi...@apache.org>.
dlg99 edited a comment on pull request #10:
URL: https://github.com/apache/pulsar-adapters/pull/10#issuecomment-815351208


   The easiest way to review is to look at the last two commits, previous commits are from pre-req https://github.com/apache/pulsar-adapters/pull/9


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



[GitHub] [pulsar-adapters] sijie commented on pull request #10: Feature: Run Kafka streams app with Pulsar

Posted by GitBox <gi...@apache.org>.
sijie commented on pull request #10:
URL: https://github.com/apache/pulsar-adapters/pull/10#issuecomment-815947679


   @BewareMyPower Can you review this PR?


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



[GitHub] [pulsar-adapters] dlg99 commented on a change in pull request #10: Feature: Run Kafka streams app with Pulsar

Posted by GitBox <gi...@apache.org>.
dlg99 commented on a change in pull request #10:
URL: https://github.com/apache/pulsar-adapters/pull/10#discussion_r610958065



##########
File path: pulsar-client-kafka-compat/pulsar-client-kafka/src/main/java/org/apache/kafka/clients/producer/PulsarKafkaProducer.java
##########
@@ -366,7 +372,15 @@ private RecordMetadata getRecordMetadata(String topic, TypedMessageBuilder<byte[
 
         TopicPartition tp = new TopicPartition(topic, partition);
         TypedMessageBuilderImpl<byte[]> mb = (TypedMessageBuilderImpl<byte[]>) msgBuilder;
-        return new RecordMetadata(tp, offset, 0L, mb.getPublishTime(), 0L, mb.hasKey() ? mb.getKey().length() : 0, size);
+
+        long publishTime = 0L;
+        try {
+            // there is no hasPublishTime() currently
+            publishTime = mb.getPublishTime();
+        } catch (IllegalStateException ise) {
+            logger.debug("could not get publish time");

Review comment:
       all messages that passed through LIneSplit example had this problem. 
   Error logging was too noisy.
   I didn't have time to investigate where it is expected to be filled in / why it was blank.




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



[GitHub] [pulsar-adapters] BewareMyPower commented on a change in pull request #10: Feature: Run Kafka streams app with Pulsar

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on a change in pull request #10:
URL: https://github.com/apache/pulsar-adapters/pull/10#discussion_r610320654



##########
File path: pulsar-client-kafka-compat/pulsar-client-kafka/src/main/java/org/apache/kafka/clients/producer/PulsarKafkaProducer.java
##########
@@ -366,7 +372,15 @@ private RecordMetadata getRecordMetadata(String topic, TypedMessageBuilder<byte[
 
         TopicPartition tp = new TopicPartition(topic, partition);
         TypedMessageBuilderImpl<byte[]> mb = (TypedMessageBuilderImpl<byte[]>) msgBuilder;
-        return new RecordMetadata(tp, offset, 0L, mb.getPublishTime(), 0L, mb.hasKey() ? mb.getKey().length() : 0, size);
+
+        long publishTime = 0L;
+        try {
+            // there is no hasPublishTime() currently
+            publishTime = mb.getPublishTime();
+        } catch (IllegalStateException ise) {
+            logger.debug("could not get publish time");

Review comment:
       Why is the log level debug? I think `sendAsync` will set the publish time and `getPublishTime()` failure is an unexpected case so here the log level should be error.

##########
File path: examples/kafka-streams/pom.xml
##########
@@ -0,0 +1,153 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.pulsar.examples</groupId>
+        <artifactId>pulsar-adapters-examples</artifactId>
+        <version>2.8.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>kafka-streams</artifactId>
+    <name>Pulsar Examples :: Kafka Streams</name>
+
+    <properties>
+        <maven.compiler.target>1.8</maven.compiler.target>
+        <maven.compiler.source>1.8</maven.compiler.source>
+    </properties>
+
+
+  <dependencies>
+    <!--dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>${slf4j.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <version>${slf4j.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <version>2.6.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <version>2.6.1</version>
+    </dependency-->

Review comment:
       Should we remove it?




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



[GitHub] [pulsar-adapters] dlg99 commented on pull request #10: Feature: Run Kafka streams app with Pulsar

Posted by GitBox <gi...@apache.org>.
dlg99 commented on pull request #10:
URL: https://github.com/apache/pulsar-adapters/pull/10#issuecomment-815351208


   The easiest way to review is to look at the last two commits, previous commits are from pre-req https://github.com/apache/pulsar-adapters/pull/10


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



[GitHub] [pulsar-adapters] eolivelli merged pull request #10: Feature: Run Kafka streams app with Pulsar

Posted by GitBox <gi...@apache.org>.
eolivelli merged pull request #10:
URL: https://github.com/apache/pulsar-adapters/pull/10


   


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