[ 
https://issues.apache.org/jira/browse/KAFKA-1049?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13760940#comment-13760940
 ] 

Jason Rosenberg commented on KAFKA-1049:
----------------------------------------

I posed this issue to the kafka users mailing list.  There were a couple 
suggestions:

Jay Kreps suggests that the producer when instantiating an encoder, could first 
try to use a constructor that takes a VerifiableProperties, and if that is not 
available, then revert to a simple no-arg constructor.

Joel Koshy suggests that VerifiableProperties could be made to extend 
Properties, and that might be an easier thing to require for the java api.

My personal feeling, is that it's hard to require implementers of an interface 
to provide a constructor of a certain signature, since there's no way to 
enforce this statically at compile time.  Perhaps instead, the interface can 
include a 'setProperties()' method, that the producer will call right after 
instantiation.
                
> Encoder implementations are required to provide an undocumented constructor.
> ----------------------------------------------------------------------------
>
>                 Key: KAFKA-1049
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1049
>             Project: Kafka
>          Issue Type: Improvement
>            Reporter: Jason Rosenberg
>            Priority: Minor
>
> So, it seems that if I want to set a custom serializer class on the producer 
> (in 0.8), I have to use a class that includes a special constructor like:
> public class MyKafkaEncoder<MyType> implements Encoder<MyType> {
>   // This constructor is expected by the kafka producer, used by reflection
>   public MyKafkaEncoder(VerifiableProperties props) {
>     // what can I do with this?
>   }
>  @Override
>   public byte[] toBytes(MyType message) {
>     return message.toByteArray();
>   }
> }
> It seems odd that this would be a requirement when implementing an interface. 
>  This seems not to have been the case in 0.7.
> What could my encoder class do with the VerifiableProperties?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to