Decathlon / tzatziki

Decathlon library to ease and promote Test Driven Development of Java microservices!
Apache License 2.0
59 stars 27 forks source link

Add the support of KafkaListeners #146

Open mamdouni opened 1 year ago

mamdouni commented 1 year ago

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

brian-mulier commented 1 year ago

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 :)

mamdouni commented 1 year ago

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

mimfgg commented 1 year ago

Hi @mamdouni should we still implement this?