[ 
https://issues.apache.org/jira/browse/BEAM-13854?focusedWorklogId=727612&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-727612
 ]

ASF GitHub Bot logged work on BEAM-13854:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 15/Feb/22 19:05
            Start Date: 15/Feb/22 19:05
    Worklog Time Spent: 10m 
      Work Description: aromanenko-dev merged pull request #16858:
URL: https://github.com/apache/beam/pull/16858


   


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 727612)
    Time Spent: 50m  (was: 40m)

> Document casting trick for Avro value serializer in KafkaIO
> -----------------------------------------------------------
>
>                 Key: BEAM-13854
>                 URL: https://issues.apache.org/jira/browse/BEAM-13854
>             Project: Beam
>          Issue Type: Improvement
>          Components: io-java-kafka
>    Affects Versions: 2.36.0
>            Reporter: Matt Casters
>            Assignee: Matt Casters
>            Priority: P3
>              Labels: pull-request-available
>             Fix For: 2.38.0
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> Consider we want to write Avro values to Kafka with for example the following 
> code:
> {code:java}
> KafkaIO.Write<String, GenericRecord> stringsToKafka =
>  KafkaIO.<String, GenericRecord>write()
>   .withBootstrapServers(bootstrapServers)
>   .withTopic(topic)
>   .withKeySerializer(StringSerializer.class)
>   .withValueSerializer(KafkaAvroSerializer.class)
>   .withProducerConfigUpdates(producerConfigUpdates);{code}
>  The KafkaAvroSerializer.class argument can't be passed as would normally be 
> the case in Producer option: 
> value.serializer=io.confluent.kafka.serializers.KafkaAvroSerializer
> So the question then is which class should we pass or how to cast. IntelliJ 
> IDEA suggests a cast which doesn't compile.
> In the end the answer is simply:
> {code:java}
>   .withValueSerializer((Class)KafkaAvroSerializer.class) {code}
> I think it's worth documenting this little trick more clearly in the Javadoc 
> of KafkaIO to prevent others from bumping into the same issue. 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to