kafka icon indicating copy to clipboard operation
kafka copied to clipboard

Initiating a consumer with multiple strategies not working

Open itai-codefresh opened this issue 9 years ago • 1 comments

I am trying to subscribe to 2 different topics, but have the handler be different. So basically i am defining a strategy array with 2 objects as following:

var strategies = [
   {
        subscriptions: ['test'],
        handler: dataHandler
    },
    {
        subscriptions: ['test1'],
        handler: dataHandler1
    }
];

What happens is that only the 'test1' topic is being consumed. This forces me to subscribe with both topics to the same handler atm.

Is this a bug? What's the point of having the init function receive an array then?

itai-codefresh avatar Nov 25 '16 14:11 itai-codefresh

Multiple strategies in Kafka are only for rolling updates of consumer groups, you can't use them simultaneously. Only a single strategy will be selected by group coordinator for all group members. So in order to use different handlers for different topics just add a split by topic logic in your single handler.

oleksiyk avatar Nov 25 '16 15:11 oleksiyk