kafka
kafka copied to clipboard
Initiating a consumer with multiple strategies not working
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?
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.