0

How to assign priorities to KAFKA TOPICS such that all consumers in all consumer groups first read from higher priority topics and if there are no messages in higher priority topics then it should shift to lower priority topics. Also how to make it preemptive such that whenever new messages arrives in Higher priority topic, consumer should shift again to them.

1 Answers1

1

You should implement that through code, one way is setting one topic with different partitions , and implement The PartitionAssignor interface , sending "high" priority key to majority of partitions , "meduim" to less and "low" to lesser, like 10,5,3 , the consumer that way will avoid starvation situations and your "high" messages would have higher processing attention

Ran Lupovich
  • 1,655
  • 1
  • 6
  • 13
  • I had implemented that case (bucket priority pattern) but I' m stuck with this case specifically where I need the consumers to switch between topics if there are no messages in higher priority ones. And should switch again in case of any incoming messages. – Krati Jain May 31 '21 at 02:51
  • This is why using one topic with partitions using consumer group should give you better implementation solution – Ran Lupovich May 31 '21 at 03:31