tzatziki icon indicating copy to clipboard operation
tzatziki copied to clipboard

Add the support of KafkaListeners

Open mamdouni opened this issue 1 year ago • 3 comments

For the moment, i'm using the same method for for the main and retry topic image if i run a somple kafka test like below : image i'm having this error : org.awaitility.core.ConditionTimeoutException: Condition with com.decathlon.tzatziki.kafka.KafkaInterceptor was not fulfilled within 10 seconds. After debugging, i found that the issue came from this code bloc from the KafkaInterceptor class (which is not executed): image Actually, it's normal. As this annotation checks only the KafkaListener annotation and by declaring multiple ones on the same method -> a KafkaListeners annotation will be added (after compilation) to englobe them for example :

public @interface Foos {
    Foo[] value();
}

// pre Java 8
@Foos({@Foo(bar="one"), @Foo(bar="two")})
public void haha() {}

// post Java 8 with @Repeatable(Foos.class) on @Foo
@Foo(bar="one") @Foo(bar="two")
public void haha() {}

source : https://stackoverflow.com/questions/1554112/multiple-annotations-of-the-same-type-on-one-element To resolve the issue, we have to add an aspect to intercept the KafkaListeners calls also

mamdouni avatar Mar 07 '23 16:03 mamdouni

Hello ! I can see the issue. As a workaround maybe you can create two methods which call the same private method in the end ? (watch out for @transactional which should be duplicate on both entry method to work since it doesn't work when calling private method).

If it is really annoying feel free to contribute :)

brian-mulier avatar Mar 07 '23 17:03 brian-mulier

Yes, For the moment, that's what i will do and thanks for the hint (i totally forget get, it's the same bean) Ok, i will create the Pull Request

mamdouni avatar Mar 07 '23 17:03 mamdouni

Hi @mamdouni should we still implement this?

mimfgg avatar May 30 '23 07:05 mimfgg