Skip to content

Commit

Permalink
Merge pull request #297 from tulios/add-duplicate-group-id-help
Browse files Browse the repository at this point in the history
Add FAQ entry for receiving data from unsubscribed topics
  • Loading branch information
Nevon authored Feb 22, 2019
2 parents ede53cd + 0f43fe9 commit 7d7a765
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/Admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
]
Expand All @@ -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']
}
Expand Down Expand Up @@ -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' }]
}]
Expand Down
6 changes: 6 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 5 additions & 0 deletions src/consumer/consumerGroup.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/utils/websiteUrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const BASE_URL = 'https://kafka.js.org'

module.exports = (path, hash) => `${BASE_URL}/${path}${hash ? '#' + hash : ''}`
15 changes: 15 additions & 0 deletions src/utils/websiteUrl.spec.js
Original file line number Diff line number Diff line change
@@ -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'
)
})
})

0 comments on commit 7d7a765

Please sign in to comment.