Skip to content

Improve Kafka documentation - #286

Merged
rosensilva merged 4 commits into
wso2:mainfrom
PasinduGunarathne:kafka-doc
May 11, 2026
Merged

Improve Kafka documentation#286
rosensilva merged 4 commits into
wso2:mainfrom
PasinduGunarathne:kafka-doc

Conversation

@PasinduGunarathne

@PasinduGunarathne PasinduGunarathne commented May 8, 2026

Copy link
Copy Markdown
Contributor

Purpose

Improve the Kafka document content with correct syntax and guidelines. Enhance the instruction to use the publisher and consumer flows of the Kafka Connector to improve maintainability and error tracking.

  • Further, the integration sample now utilizes an OrderEvent record type for end-to-end testing.(Refactor kafka integration samples integration-samples#133)
  • Integrated best practices for message tracking.
  • Users can now easily identify specific messages by inspecting Offset and Partition IDs during failures.

Goals

Describe the solutions that this feature/fix will introduce to resolve the problems described above

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter �N/A� plus brief explanation of why there�s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type �Sent� when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type �N/A� and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

Summary by CodeRabbit

  • New Features

    • Added offsetsForTimes() operation for Kafka consumers.
    • New consumer option autoSeekOnValidationFailure (default: true).
  • Behavior Changes

    • Delivery metadata (offset/timestamp) may be null in send responses.
    • subscribe() now requires groupId to be set (missing groupId causes a panic).
  • Documentation

    • Connector version bumped to v4.6.5; callback signatures and payload type clarified.
    • Examples and UI images updated; multiple consumer duration parameters now optional.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@PasinduGunarathne has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 32 minutes and 20 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 97d707e8-f27d-4fcf-bccc-d2f7768feb4a

📥 Commits

Reviewing files that changed from the base of the PR and between dc36234 and f9dd27b.

📒 Files selected for processing (1)
  • en/docs/develop/integration-artifacts/event/kafka.md

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'path_instructions'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

This PR updates Kafka connector documentation for v4.6.5, clarifying Producer and Consumer API contracts, expanding callback signature guidance, and demonstrating updated integration patterns with manual deserialization and error handling.

Changes

Kafka Connector & Integration Documentation

Layer / File(s) Summary
Consumer & Producer API Contracts
en/docs/connectors/catalog/messaging/kafka/actions.md
Producer sendWithMetadata() clarifies nullable offset and timestamp; Consumer adds autoSeekOnValidationFailure config option, warns that subscribe() panics without groupId, makes duration parameters optional across eight operations (defaulting to -1), and adds new offsetsForTimes operation with parameters and return shape.
Connector Overview & Version Reference
en/docs/connectors/catalog/messaging/kafka/connector-overview.md
Connector version updated from v4.6.3 to v4.6.5; trigger reference updated to point to BytesConsumerRecord payload structure.
onConsumerRecord Callback Signature Documentation
en/docs/connectors/catalog/messaging/kafka/triggers.md
onConsumerRecord handler signature documentation expanded to list three parameter-order variants (caller-first, records-first, caller-optional), clarifying that records array may be typed for automatic deserialization and optionally marked readonly, and that @kafka:Payload annotation may explicitly designate payload records.
Integration Example Code
en/docs/develop/integration-artifacts/event/kafka.md
Kafka listener example rewritten with configurable bootstrapServers, groupId, and kafkaTopic; handler signature changed from typed OrderEvent[] to AnydataConsumerRecord[] requiring manual deserialization; adds per-message error handling and logging; removes inline OrderEvent type and onError handler.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

I nibble docs in morning light,
v4.6.5 tuned just right.
Callbacks hum and params bend,
Examples guide from start to end.
🐇🍃

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a filled Purpose section with clear goals and related links, but most required template sections (Goals, Approach, User stories, Release note, Documentation, Training, Certification, Marketing, Automation tests, Security checks, Samples, Migrations, Test environment, Learning) are empty placeholders rather than substantive content. Complete the empty template sections: expand Goals, Approach, User stories, Release note, Documentation, Training, Certification, Marketing, Automation tests, Security checks, Samples, Migrations, Test environment, and Learning with specific details relevant to the Kafka documentation updates.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Improve Kafka documentation' directly and accurately summarizes the main change—comprehensive updates to Kafka connector documentation covering syntax corrections, configuration clarifications, and enhanced consumer/producer guidance.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
en/docs/develop/integration-artifacts/event/kafka.md (1)

73-75: Consider using the official ballerina/data.jsondata library for JSON string deserialization.

The ensureType() call without an explicit type argument (line 73) is valid—the compiler infers byte[] from the variable declaration via contextual typing.

However, fromJsonStringWithType() (line 75) is used in multiple documentation examples but is not an officially documented API. Ballerina's official recommendation for deserializing JSON strings to user-defined types is the ballerina/data.jsondata library's parseString() function, which provides a well-documented, library-based approach instead of relying on undocumented method patterns.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@en/docs/develop/integration-artifacts/event/kafka.md` around lines 73 - 75,
The docs use an undocumented method pattern: keep the ensureType() call as-is
(it can remain inferencing byte[]), but replace the undocumented json
deserialization call OrderEvent orderEvent = check
jsonStr.fromJsonStringWithType(); with the official ballerina/data.jsondata
library: import data.jsondata and use its parseString() API to parse jsonStr and
then convert/assign the result to the user-defined OrderEvent type (e.g., call
jsondata:parseString(jsonStr) and map/convert to OrderEvent or use the library's
typed parsing pattern), so the example uses the documented parseString() flow
instead of fromJsonStringWithType().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@en/docs/connectors/catalog/messaging/kafka/triggers.md`:
- Around line 98-111: The note incorrectly shows a non-existent `@kafka`:Payload
annotation; remove that example and replace it with guidance to use a typed
parameter for implicit payload binding (e.g., reference the service method
signature onConsumerRecord and the parameter MyRecord[] records) so the
connector will deserialize Kafka message bytes into the typed records
automatically; update the example line that currently reads remote function
onConsumerRecord(kafka:Caller caller, `@kafka`:Payload MyRecord[] records) returns
error? to instead show using the typed parameter (remote function
onConsumerRecord(kafka:Caller caller, MyRecord[] records) returns error?) and
adjust the surrounding text to state that payload binding is implicit and driven
by the parameter type.

---

Nitpick comments:
In `@en/docs/develop/integration-artifacts/event/kafka.md`:
- Around line 73-75: The docs use an undocumented method pattern: keep the
ensureType() call as-is (it can remain inferencing byte[]), but replace the
undocumented json deserialization call OrderEvent orderEvent = check
jsonStr.fromJsonStringWithType(); with the official ballerina/data.jsondata
library: import data.jsondata and use its parseString() API to parse jsonStr and
then convert/assign the result to the user-defined OrderEvent type (e.g., call
jsondata:parseString(jsonStr) and map/convert to OrderEvent or use the library's
typed parsing pattern), so the example uses the documented parseString() flow
instead of fromJsonStringWithType().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 247d72c9-621b-4eab-bd56-4af47aeaddd4

📥 Commits

Reviewing files that changed from the base of the PR and between a466c78 and 6432b7f.

⛔ Files ignored due to path filters (2)
  • en/static/img/connectors/catalog/messaging/kafka/kafka_producer_screenshots_05_operation_filled.png is excluded by !**/*.png
  • en/static/img/connectors/catalog/messaging/kafka/kafka_producer_screenshots_06_completed_flow.png is excluded by !**/*.png
📒 Files selected for processing (4)
  • en/docs/connectors/catalog/messaging/kafka/actions.md
  • en/docs/connectors/catalog/messaging/kafka/connector-overview.md
  • en/docs/connectors/catalog/messaging/kafka/triggers.md
  • en/docs/develop/integration-artifacts/event/kafka.md

Comment thread en/docs/connectors/catalog/messaging/kafka/triggers.md

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@en/docs/develop/integration-artifacts/event/kafka.md`:
- Around line 94-101: The example in onConsumerRecord references the OrderEvent
type but doesn't declare it, making the snippet non-runnable; add a brief
OrderEvent record definition (with fields used like orderId and any other fields
consumed by processOrder) above or within the example or add a clear comment
pointing to its declaration in functions.bal, and ensure the doc shows the
OrderEvent symbol so readers can copy a complete, runnable sample that compiles
with onConsumerRecord and processOrder.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 00c62276-12e9-4025-848f-880e1fa68e8c

📥 Commits

Reviewing files that changed from the base of the PR and between 6432b7f and dc36234.

📒 Files selected for processing (6)
  • en/docs/connectors/catalog/messaging/kafka/actions.md
  • en/docs/connectors/catalog/messaging/kafka/connector-overview.md
  • en/docs/connectors/catalog/messaging/kafka/example.md
  • en/docs/connectors/catalog/messaging/kafka/setup-guide.md
  • en/docs/connectors/catalog/messaging/kafka/triggers.md
  • en/docs/develop/integration-artifacts/event/kafka.md
✅ Files skipped from review due to trivial changes (3)
  • en/docs/connectors/catalog/messaging/kafka/setup-guide.md
  • en/docs/connectors/catalog/messaging/kafka/example.md
  • en/docs/connectors/catalog/messaging/kafka/connector-overview.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • en/docs/connectors/catalog/messaging/kafka/triggers.md

Comment thread en/docs/develop/integration-artifacts/event/kafka.md
@rosensilva
rosensilva merged commit 2ef224b into wso2:main May 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants