From fdc2b6742e790c5219487eed61ecd03c53e444bb Mon Sep 17 00:00:00 2001 From: Tommy Brunn Date: Thu, 21 Feb 2019 10:24:33 +0100 Subject: [PATCH 1/4] Add FAQ entry for receiving messages for unsubscribed topics --- docs/FAQ.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/FAQ.md b/docs/FAQ.md index 952e39679..343bbb630 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -9,6 +9,12 @@ title: Frequently Asked Questions > **Note**: If you are using KafkaJS in production, [we would love to hear about what you are doing!](https://github.com/tulios/kafkajs/issues/289) +## Why am I receiving messages for topics I'm not subscribed to? + +If you are seeing the warning `[ConsumerGroup] Consumer group received unsubscribed topics`, it likely means that some members of your consumer group are subscribed to some topics, and some other members of the group are subscribed to a different set of topics. In our experience, the most common cause is re-using `groupId` across several applications or several different independent deployments of the same application. This is normal while deploying a new version of an application where the new version subscribes to a new topic, and the warning will go away once the group stabilizes on a single version. + +Ensure that your `groupId` is not used by any other application. A simple way to verify this is to [describe the consumer group](Consuming.md#describe-group) and verify that there are no unexpected members. + ## Didn't find what you were looking for? Please [open an issue](https://github.com/tulios/kafkajs/issues) or [join our Slack community](https://kafkajs-slackin.herokuapp.com) \ No newline at end of file From 18c0ee4bee7940dd774058a1dbcf5a8b20455443 Mon Sep 17 00:00:00 2001 From: Tommy Brunn Date: Thu, 21 Feb 2019 10:27:35 +0100 Subject: [PATCH 2/4] Fix incorrect import in admin examples --- docs/Admin.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/Admin.md b/docs/Admin.md index 8c867dde6..18bcb8e34 100644 --- a/docs/Admin.md +++ b/docs/Admin.md @@ -190,12 +190,12 @@ await admin.describeConfigs({ Returning all configs for a given resource: ```javascript -const { RESOURCE_TYPES } = require('kafkajs') +const { ResourceTypes } = require('kafkajs') await admin.describeConfigs({ resources: [ { - type: RESOURCE_TYPES.TOPIC, + type: ResourceTypes.TOPIC, name: 'topic-name' } ] @@ -205,12 +205,12 @@ await admin.describeConfigs({ Returning specific configs for a given resource: ```javascript -const { RESOURCE_TYPES } = require('kafkajs') +const { ResourceTypes } = require('kafkajs') await admin.describeConfigs({ resources: [ { - type: RESOURCE_TYPES.TOPIC, + type: ResourceTypes.TOPIC, name: 'topic-name', configNames: ['cleanup.policy'] } @@ -276,11 +276,11 @@ await admin.alterConfigs({ Example: ```javascript -const { RESOURCE_TYPES } = require('kafkajs') +const { ResourceTypes } = require('kafkajs') await admin.alterConfigs({ resources: [{ - type: RESOURCE_TYPES.TOPIC, + type: ResourceTypes.TOPIC, name: 'topic-name', configEntries: [{ name: 'cleanup.policy', value: 'compact' }] }] From a3ef1725ae635769f0c3684dcccbff6a10189217 Mon Sep 17 00:00:00 2001 From: Tommy Brunn Date: Thu, 21 Feb 2019 10:28:40 +0100 Subject: [PATCH 3/4] Remove extra space --- docs/FAQ.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/FAQ.md b/docs/FAQ.md index 343bbb630..0a104b4ac 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -11,7 +11,7 @@ title: Frequently Asked Questions ## Why am I receiving messages for topics I'm not subscribed to? -If you are seeing the warning `[ConsumerGroup] Consumer group received unsubscribed topics`, it likely means that some members of your consumer group are subscribed to some topics, and some other members of the group are subscribed to a different set of topics. In our experience, the most common cause is re-using `groupId` across several applications or several different independent deployments of the same application. This is normal while deploying a new version of an application where the new version subscribes to a new topic, and the warning will go away once the group stabilizes on a single version. +If you are seeing the warning `[ConsumerGroup] Consumer group received unsubscribed topics`, it likely means that some members of your consumer group are subscribed to some topics, and some other members of the group are subscribed to a different set of topics. In our experience, the most common cause is re-using `groupId` across several applications or several different independent deployments of the same application. This is normal while deploying a new version of an application where the new version subscribes to a new topic, and the warning will go away once the group stabilizes on a single version. Ensure that your `groupId` is not used by any other application. A simple way to verify this is to [describe the consumer group](Consuming.md#describe-group) and verify that there are no unexpected members. From 0f43fe94212b83b9fb1eb568aacb7e9c0a24cd2a Mon Sep 17 00:00:00 2001 From: Tommy Brunn Date: Thu, 21 Feb 2019 14:52:00 +0100 Subject: [PATCH 4/4] Add link to faq from warn log --- src/consumer/consumerGroup.js | 5 +++++ src/utils/websiteUrl.js | 3 +++ src/utils/websiteUrl.spec.js | 15 +++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 src/utils/websiteUrl.js create mode 100644 src/utils/websiteUrl.spec.js diff --git a/src/consumer/consumerGroup.js b/src/consumer/consumerGroup.js index cff407131..dd6966f74 100644 --- a/src/consumer/consumerGroup.js +++ b/src/consumer/consumerGroup.js @@ -1,5 +1,6 @@ const flatten = require('../utils/flatten') const sleep = require('../utils/sleep') +const websiteUrl = require('../utils/websiteUrl') const arrayDiff = require('../utils/arrayDiff') const OffsetManager = require('./offsetManager') const Batch = require('./batch') @@ -169,6 +170,10 @@ module.exports = class ConsumerGroup { assignedTopics, topicsSubscribed, topicsNotSubscribed, + helpUrl: websiteUrl( + 'docs/faq', + 'why-am-i-receiving-messages-for-topics-i-m-not-subscribed-to' + ), }) // Remove unsubscribed topics from the list diff --git a/src/utils/websiteUrl.js b/src/utils/websiteUrl.js new file mode 100644 index 000000000..0e721d7b2 --- /dev/null +++ b/src/utils/websiteUrl.js @@ -0,0 +1,3 @@ +const BASE_URL = 'https://kafka.js.org' + +module.exports = (path, hash) => `${BASE_URL}/${path}${hash ? '#' + hash : ''}` diff --git a/src/utils/websiteUrl.spec.js b/src/utils/websiteUrl.spec.js new file mode 100644 index 000000000..5dc0d8549 --- /dev/null +++ b/src/utils/websiteUrl.spec.js @@ -0,0 +1,15 @@ +const websiteUrl = require('./websiteUrl') + +describe('Utils > websiteUrl', () => { + it('generates links to the website', () => { + expect(websiteUrl('docs/faq')).toEqual('https://kafka.js.org/docs/faq') + }) + + it('allows specifying a hash', () => { + expect( + websiteUrl('docs/faq', 'why-am-i-receiving-messages-for-topics-i-m-not-subscribed-to') + ).toEqual( + 'https://kafka.js.org/docs/faq#why-am-i-receiving-messages-for-topics-i-m-not-subscribed-to' + ) + }) +})