Understanding how multithreading works in an existing application

I got brought into a new team handling this multithreaded multimicroservice spring java/python application which uses kafka

I have a high level understanding and experience with multithreading/kafka however I'm struggling to debug an intermittent bug.

I suspect it is likely some conflict between threads but I'm not experienced enough to understand deeper

When I run through a simple task for the application I notice methods get called three or four times (which i suspect may be causing the issue) but how do I understand how all these multiple method calls are being called from?

Are multiple threads being created somewhere? Could it be that kafla is sending the same message multiple times because the receiver is not properly subscribing?

Does anyone have any advice?

1 answer

  • answered 2020-08-11 06:58 Oleg Kaplun

    Make sure that all of the consumers are subscribing with the same consumer group, look for something like props.put("group.id", XXX); in the code.

    There is also the possibility that your code throws an exception during the consume process and the offset is not being committed, that results the same message being consume over and over again.

    In any case I would try to go and put a breakpoint in the first line of the callback function of the consumer and debug it from there.

    In case you can't debug from your host, I would probably try putting some log lines which will print the stacktraces in order to identify the caller.