vertx-kafka-client icon indicating copy to clipboard operation
vertx-kafka-client copied to clipboard

`KafkaConsumer.rxCommit(Map<TopicPartition, OffsetAndMetadata>)` missing

Open MartinNowak opened this issue 7 years ago • 7 comments

Looks like sth. went wrong during codegen, both

void commit(Map<TopicPartition, OffsetAndMetadata>, Handler<AsyncResult<Map<TopicPartition, OffsetAndMetadata>>>);

and

Single<Map<TopicPartition, OffsetAndMetadata>> rxCommit(Map<TopicPartition, OffsetAndMetadata>);

are missing from io.vertx.reactivex.kafka.client.consumer.KafkaConsumer and io.vertx.rxjava.kafka.client.consumer.KafkaConsumer.

javap -classpath vertx-kafka-client-3.5.0.jar io.vertx.reactivex.kafka.client.consumer.KafkaConsumer | grep -Fi commit\(

http://vertx.io/docs/apidocs/io/vertx/kafka/client/consumer/KafkaConsumer.html#commit-java.util.Map-io.vertx.core.Handler- http://vertx.io/docs/apidocs/io/vertx/reactivex/kafka/client/consumer/KafkaConsumer.html#commit-io.vertx.core.Handler- http://vertx.io/docs/apidocs/io/vertx/rxjava/kafka/client/consumer/KafkaConsumer.html#commit-io.vertx.core.Handler-

Maybe the Handler<AsyncResult<Map<TopicPartition, OffsetAndMetadata>>> type is too complex for the codegen parser?

MartinNowak avatar Jan 12 '18 01:01 MartinNowak

Workaround from https://github.com/vert-x3/vertx-rx/blob/65bcf1c87c0c74646d6bcc7354ae8d0d86b9efa8/rx-java2/src/main/resources/vertx-rxjava2/template/rxjava2.templ#L121-L125

new AsyncResultSingle(handler -> {
  kafkaConsumer.delegate.commit(topicOffsetMap, handler);
});

MartinNowak avatar Jan 12 '18 02:01 MartinNowak

is the method annotated with @GenIgnore ?

vietj avatar Jan 12 '18 07:01 vietj

@vietj yes it is. I guess it's because this kind of Map with more complex types isn't supported by vertx-codgen. I read the following from the documentation :

type java.util.Map<String, C> where C contains the set Basic the set Json the set Api

ppatierno avatar Jan 12 '18 09:01 ppatierno

Handler<AsyncResult<Map<TopicPartition,OffsetAndMetadata>>> completionHandler What's the trouble with template arguments? Shouldn't they just be the same as in the original code?

Not such a big deal if you know the undocumented workaround, but still quite confusing.

MartinNowak avatar Jan 17 '18 19:01 MartinNowak

Ah, you're using reflection for this. https://github.com/vert-x3/vertx-codegen/blob/7f8b20bc18ca585f43bdd9c1b7d412dd739eedc9/src/main/java/io/vertx/codegen/type/TypeReflectionFactory.java#L86-L94 Looks like it doesn't recurse for the arguments.

So this https://github.com/vert-x3/vertx-rx/blob/65bcf1c87c0c74646d6bcc7354ae8d0d86b9efa8/rx-java2/src/main/resources/vertx-rxjava2/template/rxjava2.templ#L18-L28 code would only lead to

Single<Map> rxCommit(Map<TopicPartition, OffsetAndMetadata>>)

instead of

Single<Map<TopicPartition, OffsetAndMetadata>> rxCommit(Map<TopicPartition, OffsetAndMetadata>>) , right?

MartinNowak avatar Jan 17 '18 19:01 MartinNowak

it does not recurse argument because it would lead to a too complex implementation, the actual rx wrappers need to maintain the type arguments as reified types

if you need to access them, you should use getDelegate() to obtain the real java type and rewrap it using SingleHelper or RxHelper.

vietj avatar Jan 17 '18 20:01 vietj

Unfortunately SingleHelper doesn't work here (it's vice versa) and RxHelper in rx-java2 has no observableFuture. So I'll stick with using the interal AsyncResultSingle for now.

Let me finally suggest that you create some dummy documentation entries (e.g. void rxCommit()) for @GenIgnore methods that state the fact that the method is missing and show the suggested workaround instead.

MartinNowak avatar Feb 02 '18 16:02 MartinNowak