Kafka Producer design - multiple topics

PDsilva

I'm trying to implement a Kafka producer/consumer model, and am deliberating whether creating a separate publisher thread per topic would be preferred over having a single publisher handle multiple topics. Any help would be appreciated

PS: I'm new to Kafka

JavaTechnical

By separate publisher thread, I think you mean separate producer objects. If so..

Since messages are stored as key-value pairs in Kafka, different topics can have different key-value types. So if your Kafka topics have different key-value types like for example..

Topic1 - key:String, value:Student
Topic2 - key:Long, value:Teacher

and so on, then you should be using multiple producers. This is because the KafkaProducer class at the time of constructing the object asks you for the key and value serializers.

Properties props=new Properties();
props.put("key.serializer",StringSerializer.class);
props.put("value.serializer",LongSerializer.class);
KafkaProducer<String,Long> producer=new KafkaProducer<>(props);

Though, you may also write a generic serializer for all the types! But, it is better to know before hand what we are doing with the producer.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Understanding Kafka Topics and Partitions

分類Dev

Correlating in Kafka and dynamic topics

分類Dev

Improving performance of Kafka Producer

分類Dev

Kafka Authentication Producer Unable to Connect Producer

分類Dev

How to create topics in apache kafka?

分類Dev

Kafka producer sending invalid characters

分類Dev

kafka: keep track of producer offset

分類Dev

Kafka architecture many partitions or many topics?

分類Dev

Kafka through microservices, subscribe to non exists topics

分類Dev

Does KStream autocreate topics in kafka 2.2?

分類Dev

Send message to different Kafka topics based on configuration

分類Dev

Invalid Timestamp when writing a Kafka producer with sarama

分類Dev

How to enable Kafka Producer Metrics in Spark?

分類Dev

One producer Multiple Consumer performance

分類Dev

Android firebase true way for subscribe to multiple topics

分類Dev

add and edit multiple topics using redux form

分類Dev

Kafka stream: "TopicAuthorizationException: Not authorized to access topics" for an internal state store

分類Dev

How to split the csv data to two different kafka topics based on filter

分類Dev

How to programmatically create topics using kafka-python?

分類Dev

Kafka Producer Callbackパフォーマンス

分類Dev

How to Improve Performance of Kafka Producer when used in Synchronous Mode

分類Dev

Kafka producer and consumer on separate computers aren't communicating

分類Dev

Spring-Kafka Integration 1.0.0.RELEASE Issue with Producer

分類Dev

Kafka 2.9.1 producer 0.8.2.1 compile vs runtime dependencies

分類Dev

Java/Scala Kafka Producer does not send message to topic

分類Dev

Kafka Producer deployed on Kubernetes not able to produce to Kafka cluster running on local machine

分類Dev

Question about using the @KafkaListener autoStartup = "false" for multiple topics

分類Dev

lock free single producer multiple consumer data struct using atomic

分類Dev

What is the simplest Spring Kafka @KafkaListener configuration to consume all records from a set of compacted topics?

Related 関連記事

  1. 1

    Understanding Kafka Topics and Partitions

  2. 2

    Correlating in Kafka and dynamic topics

  3. 3

    Improving performance of Kafka Producer

  4. 4

    Kafka Authentication Producer Unable to Connect Producer

  5. 5

    How to create topics in apache kafka?

  6. 6

    Kafka producer sending invalid characters

  7. 7

    kafka: keep track of producer offset

  8. 8

    Kafka architecture many partitions or many topics?

  9. 9

    Kafka through microservices, subscribe to non exists topics

  10. 10

    Does KStream autocreate topics in kafka 2.2?

  11. 11

    Send message to different Kafka topics based on configuration

  12. 12

    Invalid Timestamp when writing a Kafka producer with sarama

  13. 13

    How to enable Kafka Producer Metrics in Spark?

  14. 14

    One producer Multiple Consumer performance

  15. 15

    Android firebase true way for subscribe to multiple topics

  16. 16

    add and edit multiple topics using redux form

  17. 17

    Kafka stream: "TopicAuthorizationException: Not authorized to access topics" for an internal state store

  18. 18

    How to split the csv data to two different kafka topics based on filter

  19. 19

    How to programmatically create topics using kafka-python?

  20. 20

    Kafka Producer Callbackパフォーマンス

  21. 21

    How to Improve Performance of Kafka Producer when used in Synchronous Mode

  22. 22

    Kafka producer and consumer on separate computers aren't communicating

  23. 23

    Spring-Kafka Integration 1.0.0.RELEASE Issue with Producer

  24. 24

    Kafka 2.9.1 producer 0.8.2.1 compile vs runtime dependencies

  25. 25

    Java/Scala Kafka Producer does not send message to topic

  26. 26

    Kafka Producer deployed on Kubernetes not able to produce to Kafka cluster running on local machine

  27. 27

    Question about using the @KafkaListener autoStartup = "false" for multiple topics

  28. 28

    lock free single producer multiple consumer data struct using atomic

  29. 29

    What is the simplest Spring Kafka @KafkaListener configuration to consume all records from a set of compacted topics?

ホットタグ

アーカイブ