├── .editorconfig
├── .github
├── maven-cd-settings.xml
├── maven-ci-settings.xml
└── workflows
│ ├── ci-4.x.yml
│ ├── ci-5.x-stable.yml
│ ├── ci-5.x.yml
│ ├── ci-matrix-5.x.yml
│ ├── ci.yml
│ └── deploy.yml
├── .gitignore
├── LICENSE.txt
├── README.md
├── pom.xml
└── src
├── main
├── asciidoc
│ ├── adminclient.adoc
│ ├── index.adoc
│ └── rxjava2.adoc
├── generated
│ └── io
│ │ └── vertx
│ │ └── kafka
│ │ ├── admin
│ │ ├── ClusterDescriptionConverter.java
│ │ ├── ConfigConverter.java
│ │ ├── ConfigEntryConverter.java
│ │ ├── ConfigSynonymConverter.java
│ │ ├── ConsumerGroupDescriptionConverter.java
│ │ ├── ConsumerGroupListingConverter.java
│ │ ├── DescribeClusterOptionsConverter.java
│ │ ├── DescribeConsumerGroupsOptionsConverter.java
│ │ ├── DescribeTopicsOptionsConverter.java
│ │ ├── ListConsumerGroupOffsetsOptionsConverter.java
│ │ ├── ListOffsetsResultInfoConverter.java
│ │ ├── MemberAssignmentConverter.java
│ │ ├── MemberDescriptionConverter.java
│ │ ├── NewPartitionsConverter.java
│ │ ├── NewTopicConverter.java
│ │ ├── OffsetSpecConverter.java
│ │ └── TopicDescriptionConverter.java
│ │ └── client
│ │ └── common
│ │ ├── ConfigResourceConverter.java
│ │ ├── KafkaClientOptionsConverter.java
│ │ ├── PartitionInfoConverter.java
│ │ └── TopicPartitionInfoConverter.java
└── java
│ ├── examples
│ ├── KafkaAdminClientExamples.java
│ ├── VertxKafkaClientExamples.java
│ └── package-info.java
│ └── io
│ └── vertx
│ └── kafka
│ ├── admin
│ ├── ClusterDescription.java
│ ├── Config.java
│ ├── ConfigEntry.java
│ ├── ConfigSynonym.java
│ ├── ConsumerGroupDescription.java
│ ├── ConsumerGroupListing.java
│ ├── DescribeClusterOptions.java
│ ├── DescribeConsumerGroupsOptions.java
│ ├── DescribeTopicsOptions.java
│ ├── KafkaAdminClient.java
│ ├── ListConsumerGroupOffsetsOptions.java
│ ├── ListOffsetsResultInfo.java
│ ├── MemberAssignment.java
│ ├── MemberDescription.java
│ ├── NewPartitions.java
│ ├── NewTopic.java
│ ├── OffsetSpec.java
│ ├── TopicDescription.java
│ ├── impl
│ │ └── KafkaAdminClientImpl.java
│ └── package-info.java
│ └── client
│ ├── common
│ ├── ConfigResource.java
│ ├── KafkaClientOptions.java
│ ├── Node.java
│ ├── PartitionInfo.java
│ ├── TopicPartition.java
│ ├── TopicPartitionInfo.java
│ ├── impl
│ │ ├── CloseHandler.java
│ │ └── Helper.java
│ └── tracing
│ │ ├── ConsumerTracer.java
│ │ ├── ProducerTracer.java
│ │ ├── TraceContext.java
│ │ └── TraceTags.java
│ ├── consumer
│ ├── KafkaConsumer.java
│ ├── KafkaConsumerRecord.java
│ ├── KafkaConsumerRecords.java
│ ├── KafkaReadStream.java
│ ├── OffsetAndMetadata.java
│ ├── OffsetAndTimestamp.java
│ └── impl
│ │ ├── KafkaConsumerImpl.java
│ │ ├── KafkaConsumerRecordImpl.java
│ │ ├── KafkaConsumerRecordsImpl.java
│ │ └── KafkaReadStreamImpl.java
│ ├── package-info.java
│ ├── producer
│ ├── KafkaHeader.java
│ ├── KafkaProducer.java
│ ├── KafkaProducerRecord.java
│ ├── KafkaWriteStream.java
│ ├── RecordMetadata.java
│ └── impl
│ │ ├── KafkaHeaderImpl.java
│ │ ├── KafkaProducerImpl.java
│ │ ├── KafkaProducerRecordImpl.java
│ │ └── KafkaWriteStreamImpl.java
│ └── serialization
│ ├── BufferDeserializer.java
│ ├── BufferSerializer.java
│ ├── JsonArrayDeserializer.java
│ ├── JsonArraySerializer.java
│ ├── JsonObjectDeserializer.java
│ ├── JsonObjectSerializer.java
│ └── VertxSerdes.java
└── test
└── java
└── io
└── vertx
└── kafka
└── client
├── common
└── tracing
│ └── TracingTest.java
└── tests
├── AdminClientAclTest.java
├── AdminClientConfigEntryTest.java
├── AdminClientTest.java
├── CleanupTest.java
├── CodecsTest.java
├── ConsumerFailedCloseTest.java
├── ConsumerMockTest.java
├── ConsumerMockTestBase.java
├── ConsumerTest.java
├── ConsumerTestBase.java
├── EarliestNativeTest.java
├── EarliestTest.java
├── KafkaClusterTestBase.java
├── KafkaHeaderTest.java
├── KafkaReadStreamMockTest.java
├── KafkaTestBase.java
├── NoClusterTest.java
├── ProducerConsumerContextTest.java
├── ProducerMockTest.java
├── ProducerTest.java
├── TopicPartitionTest.java
└── TransactionalProducerTest.java
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | trim_trailing_whitespace = true
8 | end_of_line = lf
9 | insert_final_newline = true
10 |
--------------------------------------------------------------------------------
/.github/maven-cd-settings.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 | false
20 |
21 |
22 |
23 | vertx-snapshots-repository
24 | ${env.VERTX_NEXUS_USERNAME}
25 | ${env.VERTX_NEXUS_PASSWORD}
26 |
27 |
28 |
29 |
30 |
31 | google-mirror
32 |
33 | true
34 |
35 |
36 |
37 | google-maven-central
38 | GCS Maven Central mirror EU
39 | https://maven-central.storage-download.googleapis.com/maven2/
40 |
41 | true
42 |
43 |
44 | false
45 |
46 |
47 |
48 |
49 |
50 | google-maven-central
51 | GCS Maven Central mirror
52 | https://maven-central.storage-download.googleapis.com/maven2/
53 |
54 | true
55 |
56 |
57 | false
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/.github/maven-ci-settings.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 | false
20 |
21 |
22 |
23 | google-mirror
24 |
25 | true
26 |
27 |
28 |
29 | google-maven-central
30 | GCS Maven Central mirror EU
31 | https://maven-central.storage-download.googleapis.com/maven2/
32 |
33 | true
34 |
35 |
36 | false
37 |
38 |
39 |
40 |
41 |
42 | google-maven-central
43 | GCS Maven Central mirror
44 | https://maven-central.storage-download.googleapis.com/maven2/
45 |
46 | true
47 |
48 |
49 | false
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/.github/workflows/ci-4.x.yml:
--------------------------------------------------------------------------------
1 | name: vertx-kafka-client (4.x)
2 | on:
3 | schedule:
4 | - cron: '0 4 * * *'
5 | jobs:
6 | CI:
7 | strategy:
8 | matrix:
9 | include:
10 | - os: ubuntu-latest
11 | jdk: 8
12 | - os: ubuntu-latest
13 | jdk: 17
14 | uses: ./.github/workflows/ci.yml
15 | with:
16 | branch: 4.x
17 | jdk: ${{ matrix.jdk }}
18 | os: ${{ matrix.os }}
19 | secrets: inherit
20 | Deploy:
21 | if: ${{ github.repository_owner == 'vert-x3' && (github.event_name == 'push' || github.event_name == 'schedule') }}
22 | needs: CI
23 | uses: ./.github/workflows/deploy.yml
24 | with:
25 | branch: 4.x
26 | jdk: 8
27 | secrets: inherit
28 |
--------------------------------------------------------------------------------
/.github/workflows/ci-5.x-stable.yml:
--------------------------------------------------------------------------------
1 | name: vertx-kafka-client (5.x-stable)
2 | on:
3 | push:
4 | branches:
5 | - '5.[0-9]+'
6 | pull_request:
7 | branches:
8 | - '5.[0-9]+'
9 | schedule:
10 | - cron: '0 6 * * *'
11 | jobs:
12 | CI-CD:
13 | uses: ./.github/workflows/ci-matrix-5.x.yml
14 | secrets: inherit
15 | with:
16 | branch: ${{ github.event_name == 'schedule' && vars.VERTX_5_STABLE_BRANCH || github.event.pull_request.head.sha || github.ref_name }}
17 |
--------------------------------------------------------------------------------
/.github/workflows/ci-5.x.yml:
--------------------------------------------------------------------------------
1 | name: vertx-kafka-client (5.x)
2 | on:
3 | push:
4 | branches:
5 | - master
6 | pull_request:
7 | branches:
8 | - master
9 | schedule:
10 | - cron: '0 5 * * *'
11 | jobs:
12 | CI-CD:
13 | uses: ./.github/workflows/ci-matrix-5.x.yml
14 | secrets: inherit
15 | with:
16 | branch: ${{ github.event.pull_request.head.sha || github.ref_name }}
17 |
--------------------------------------------------------------------------------
/.github/workflows/ci-matrix-5.x.yml:
--------------------------------------------------------------------------------
1 | name: CI matrix (5.x)
2 | on:
3 | workflow_call:
4 | inputs:
5 | branch:
6 | required: true
7 | type: string
8 | jobs:
9 | CI:
10 | strategy:
11 | matrix:
12 | include:
13 | - os: ubuntu-latest
14 | jdk: 11
15 | - os: ubuntu-latest
16 | jdk: 21
17 | uses: ./.github/workflows/ci.yml
18 | with:
19 | branch: ${{ inputs.branch }}
20 | jdk: ${{ matrix.jdk }}
21 | os: ${{ matrix.os }}
22 | secrets: inherit
23 | Deploy:
24 | if: ${{ github.repository_owner == 'vert-x3' && (github.event_name == 'push' || github.event_name == 'schedule') }}
25 | needs: CI
26 | uses: ./.github/workflows/deploy.yml
27 | with:
28 | branch: ${{ inputs.branch }}
29 | jdk: 11
30 | secrets: inherit
31 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | workflow_call:
4 | inputs:
5 | branch:
6 | required: true
7 | type: string
8 | jdk:
9 | default: 8
10 | type: string
11 | os:
12 | default: ubuntu-latest
13 | type: string
14 | jobs:
15 | Test:
16 | name: Run tests
17 | runs-on: ${{ inputs.os }}
18 | steps:
19 | - name: Checkout
20 | uses: actions/checkout@v2
21 | with:
22 | ref: ${{ inputs.branch }}
23 | - name: Install JDK
24 | uses: actions/setup-java@v4
25 | with:
26 | java-version: |
27 | ${{ inputs.jdk }}
28 | 17
29 | distribution: temurin
30 | - name: Run tests
31 | run: mvn -s .github/maven-ci-settings.xml -q clean verify -B
32 |
--------------------------------------------------------------------------------
/.github/workflows/deploy.yml:
--------------------------------------------------------------------------------
1 | name: Deploy
2 | on:
3 | workflow_call:
4 | inputs:
5 | branch:
6 | required: true
7 | type: string
8 | jdk:
9 | default: 8
10 | type: string
11 | jobs:
12 | Deploy:
13 | name: Deploy to OSSRH
14 | runs-on: ubuntu-latest
15 | env:
16 | VERTX_NEXUS_USERNAME: ${{ secrets.VERTX_NEXUS_USERNAME }}
17 | VERTX_NEXUS_PASSWORD: ${{ secrets.VERTX_NEXUS_PASSWORD }}
18 | steps:
19 | - name: Checkout
20 | uses: actions/checkout@v2
21 | with:
22 | ref: ${{ inputs.branch }}
23 | - name: Install JDK
24 | uses: actions/setup-java@v4
25 | with:
26 | java-version: |
27 | ${{ inputs.jdk }}
28 | 17
29 | distribution: temurin
30 | - name: Get project version
31 | run: echo "PROJECT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:evaluate -Dexpression=project.version -q -DforceStdout | grep -v '\[')" >> $GITHUB_ENV
32 | - name: Maven deploy
33 | if: ${{ endsWith(env.PROJECT_VERSION, '-SNAPSHOT') }}
34 | run: mvn deploy -s .github/maven-cd-settings.xml -DskipTests -B
35 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .gradle
3 | .idea
4 | .classpath
5 | .project
6 | .settings
7 | .yardoc
8 | .yardopts
9 | build
10 | target
11 | out
12 | *.iml
13 | *.ipr
14 | *.iws
15 | .vertx
16 | test-output
17 | src/scratchpad
18 | test-results
19 | test-tmp
20 | *.class
21 | *.swp
22 | .vertx
23 | .vscode
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Vert.x Kafka Client
2 |
3 | [](https://github.com/vert-x3/vertx-kafka-client/actions/workflows/ci-5.x.yml)
4 | [](https://github.com/vert-x3/vertx-kafka-client/actions/workflows/ci-4.x.yml)
5 |
6 | This component provides a Kafka client for reading and sending messages from/to an [Apache Kafka](https://kafka.apache.org/) cluster.
7 | From the consumer point of view, its API provides a bunch of methods for subscribing to a topic partition receiving
8 | messages asynchronously or reading them as a stream (even with the possibility to pause the stream itself).
9 | As producer, its API provides methods for sending message to a topic partition like writing on a stream.
10 |
11 | See the online docs for more details:
12 | - [Java](https://vertx.io/docs/vertx-kafka-client/java)
13 | - [JavaScript](https://vertx.io/docs/vertx-kafka-client/js)
14 | - [Ruby](https://vertx.io/docs/vertx-kafka-client/ruby)
15 | - [Groovy](https://vertx.io/docs/vertx-kafka-client/groovy)
16 | - [Kotlin](https://vertx.io/docs/vertx-kafka-client/kotlin)
17 |
18 | Important aspects of Topic Management, such as creating a topic, deleting a topic, changing configuration of a topic, are also supported.
19 | See the online docs for more details:
20 | - [Java](https://vertx.io/docs/vertx-kafka-client/java/#_vert_x_kafka_adminutils)
21 | - [JavaScript](https://vertx.io/docs/vertx-kafka-client/js/#_vert_x_kafka_adminutils)
22 | - [Ruby](https://vertx.io/docs/vertx-kafka-client/ruby/#_vert_x_kafka_adminutils)
23 | - [Groovy](https://vertx.io/docs/vertx-kafka-client/groovy/#_vert_x_kafka_adminutils)
24 | - [Kotlin](https://vertx.io/docs/vertx-kafka-client/kotlin/#_vert_x_kafka_adminutils)
25 |
26 | **Note: This module has Tech Preview status, this means the API can change between versions.**
27 |
--------------------------------------------------------------------------------
/src/main/asciidoc/adminclient.adoc:
--------------------------------------------------------------------------------
1 | == Vert.x Kafka Admin Client
2 | :toc: left
3 | :lang: $lang
4 | :$lang: $lang
5 |
6 | This component provides a Vert.x wrapper around the Kafka Admin Client API.
7 | The Kafka Admin Client is used to create, modify, and delete topics.
8 | It also provides methods for handling ACLs (Access Control Lists), consumer groups and many more.
9 |
10 | === Creating the Kafka Admin Client
11 |
12 | Creating the admin client is quite similar on how it works using the native Kafka client library.
13 |
14 | It needs to be configured with a bunch of properties as described in the official
15 | Apache Kafka documentation, for the link:https://kafka.apache.org/documentation/#adminclientconfigs[admin].
16 |
17 | To achieve that, a map can be configured with such properties passing it to one of the
18 | static creation methods exposed by {@link io.vertx.kafka.admin.KafkaAdminClient}.
19 |
20 | [source,$lang]
21 | ----
22 | {@link examples.KafkaAdminClientExamples#exampleCreateAdminClient}
23 | ----
24 |
25 | === Listing topics
26 |
27 | You can call the {@link io.vertx.kafka.admin.KafkaAdminClient#listTopics} for listing the topics in the cluster.
28 | The only parameter is the usual callback to handle the result, which provides the topics list.
29 |
30 | [source,$lang]
31 | ----
32 | {@link examples.KafkaAdminClientExamples#exampleListTopics}
33 | ----
34 |
35 | === Describe topics
36 |
37 | You can call {@link io.vertx.kafka.admin.KafkaAdminClient#describeTopics} to describe topics in the cluster.
38 | Describing a topic means getting all related metadata like number of partitions, replicas, leader, in-sync replicas and so on.
39 | The needed parameters are the list of topics names to describe, and the usual callback to handle the result providing
40 | a map with topic names and related {@link io.vertx.kafka.admin.TopicDescription}.
41 |
42 | [source,$lang]
43 | ----
44 | {@link examples.KafkaAdminClientExamples#exampleDescribeTopics}
45 | ----
46 |
47 | === Create topic
48 |
49 | You can call {@link io.vertx.kafka.admin.KafkaAdminClient#createTopics} to create topics in the cluster.
50 | The needed parameters are the list of the topics to create, and the usual callback to handle the result.
51 | The topics to create are defined via the {@link io.vertx.kafka.admin.NewTopic} class specifying the name, the number of
52 | partitions and the replication factor.
53 | It is also possible to describe the replicas assignment, mapping each replica to the broker id, instead of specifying the
54 | number of partitions and the replication factor (which in this case has to be set to -1).
55 |
56 | [source,$lang]
57 | ----
58 | {@link examples.KafkaAdminClientExamples#exampleCreateTopics}
59 | ----
60 |
61 | === Delete topic
62 |
63 | You can call {@link io.vertx.kafka.admin.KafkaAdminClient#deleteTopics} to delete topics in the cluster.
64 | The needed parameters are the list of the topics to delete, and the usual callback to handle the result.
65 |
66 | [source,$lang]
67 | ----
68 | {@link examples.KafkaAdminClientExamples#exampleDeleteTopics}
69 | ----
70 |
71 | === Describe configuration
72 |
73 | You can call {@link io.vertx.kafka.admin.KafkaAdminClient#describeConfigs} to describe resources configuration.
74 | Describing resources configuration means getting all configuration information for cluster resources like topics or brokers.
75 | The needed parameters are the list of the resources for which you want the configuration, and the usual callback to handle the result.
76 | The resources are described by a collection of {@link io.vertx.kafka.client.common.ConfigResource} while the result maps
77 | each resource with a corresponding {@link io.vertx.kafka.admin.Config} which as more {@link io.vertx.kafka.admin.ConfigEntry} for
78 | each configuration parameter.
79 |
80 | [source,$lang]
81 | ----
82 | {@link examples.KafkaAdminClientExamples#exampleDescribeConfigs}
83 | ----
84 |
85 | === Alter configuration
86 |
87 | You can call {@link io.vertx.kafka.admin.KafkaAdminClient#alterConfigs} to alter resources configuration.
88 | Altering resources configuration means updating configuration information for cluster resources like topics or brokers.
89 | The needed parameters are the list of the resources with the related configurations to updated, and the usual callback to handle the result.
90 | It is possible to alter configurations for different resources with just one call. The input parameter maps each
91 | {@link io.vertx.kafka.client.common.ConfigResource} with the corresponding {@link io.vertx.kafka.admin.Config} you want to apply.
92 |
93 | [source,$lang]
94 | ----
95 | {@link examples.KafkaAdminClientExamples#exampleAlterConfigs}
96 | ----
97 |
98 | === List consumer groups
99 |
100 | You can call the {@link io.vertx.kafka.admin.KafkaAdminClient#listConsumerGroups} for listing the consumer groups in the cluster.
101 | The only parameter is the usual callback to handle the result, which provides the consumer groups list.
102 |
103 | [source,$lang]
104 | ----
105 | {@link examples.KafkaAdminClientExamples#exampleListConsumerGroups}
106 | ----
107 |
108 | === Describe consumer groups
109 |
110 | You can call {@link io.vertx.kafka.admin.KafkaAdminClient#describeConsumerGroups} to describe consumer groups in the cluster.
111 | Describing a consumer group means getting all related information like members, related ids, topics subscribed, partitions assignment and so on.
112 | The needed parameters are the list of consumer groups names to describe, and the usual callback to handle the result providing
113 | a map with consumer group names and related {@link io.vertx.kafka.admin.MemberDescription}.
114 |
115 | [source,$lang]
116 | ----
117 | {@link examples.KafkaAdminClientExamples#exampleDescribeTopics}
118 | ----
119 |
--------------------------------------------------------------------------------
/src/main/asciidoc/rxjava2.adoc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vert-x3/vertx-kafka-client/c24056f2c52d1879f2b0c3f980ee020a1387769b/src/main/asciidoc/rxjava2.adoc
--------------------------------------------------------------------------------
/src/main/generated/io/vertx/kafka/admin/ClusterDescriptionConverter.java:
--------------------------------------------------------------------------------
1 | package io.vertx.kafka.admin;
2 |
3 | import io.vertx.core.json.JsonObject;
4 | import io.vertx.core.json.JsonArray;
5 | import java.time.Instant;
6 | import java.time.format.DateTimeFormatter;
7 |
8 | /**
9 | * Converter and mapper for {@link io.vertx.kafka.admin.ClusterDescription}.
10 | * NOTE: This class has been automatically generated from the {@link io.vertx.kafka.admin.ClusterDescription} original class using Vert.x codegen.
11 | */
12 | public class ClusterDescriptionConverter {
13 |
14 | static void fromJson(Iterable> json, ClusterDescription obj) {
15 | for (java.util.Map.Entry member : json) {
16 | switch (member.getKey()) {
17 | case "nodes":
18 | if (member.getValue() instanceof JsonArray) {
19 | java.util.ArrayList list = new java.util.ArrayList<>();
20 | ((Iterable