You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -76,133 +76,182 @@ WARNING: This content is generated by running npm --prefix .build run generate:a
76
76
END GENERATED ATTRIBUTES
77
77
////
78
78
79
-
[id="chap-produce-consume-rhoas-cli"]
80
-
= Getting started with producing and conuming messages in Rhoas Cli for {product-long-kafka}
79
+
[id="chap-producing-consuming-rhoas-cli"]
80
+
= Producing and consuming messages using the rhoas CLI
81
81
ifdef::context[:parent-context: {context}]
82
-
:context: getting-started-produce-consume
82
+
:context: produce-consume-rhoas-cli
83
83
84
84
// Purpose statement for the assembly
85
85
[role="_abstract"]
86
-
As a developer of applications and services, you can use the Rhoas Cli to create and read message in {product-long-kafka}and third-party systems.
86
+
As a developer of applications and services, you can use the `rhoas` command-line interface (CLI) to produce and consume messages for Kafka instances in {product-long-kafka}. This is a useful way to test and debug your Kafka instances.
87
87
88
-
In this example, you will produce messages to a kafka instance and consume them in the Rhoas Cli.
88
+
.Prerequisites
89
+
ifndef::community[]
90
+
* You have a Red Hat account.
91
+
endif::[]
92
+
* You have a running Kafka instance in {product-kafka}.
93
+
* You've installed the latest version of the `rhoas` CLI. See {base-url}{installation-guide-url-cli}[Installing and configuring the rhoas CLI^].
89
94
90
95
// Condition out QS-only content so that it doesn't appear in docs.
91
96
// All QS anchor IDs must be in this alternate anchor ID format `[#anchor-id]` because the ascii splitter relies on the other format `[id="anchor-id"]` to generate module files.
92
97
ifdef::qs[]
93
98
[#description]
94
99
====
95
-
Learn how to produce and consume message in {product-long-rhoas}.
100
+
Learn how to use the `rhoas` command-line interface (CLI) to produce and consume messages for a Kafka instance.
96
101
====
97
102
98
103
[#introduction]
99
104
====
100
-
Welcome to the quick start for producing and consuming messages in the Rhoas Cli.
101
-
102
-
In this quick start, you will learn how to produce messages to a kafka instance and consume them in the Rhoas Cli.
103
-
105
+
Welcome to the quick start for producing and consuming Kafka messages using the `rhoas` command-line interface (CLI).
104
106
107
+
In this quick start, you'll use a CLI command to produce messages to different topic partitions in a Kafka instance. You'll then use the {product-long-kafka} web console to inspect the messages. When you're ready, you'll use another CLI command to consume the messages.
105
108
====
106
109
endif::[]
107
110
108
-
ifndef::qs[]
109
-
== Overview
110
-
111
-
{product-long-kafka} is a cloud service that simplifies the process of running Apache Kafka. Apache Kafka is an open-source, distributed, publish-subscribe messaging system for creating fault-tolerant, real-time data feeds.
112
-
113
-
You can use {product-long-connectors} to configure communication between {product-kafka} instances and external services and applications. {product-long-connectors} allow you to configure how data moves from one endpoint to another without writing code.
114
-
115
-
The following diagram illustrates how data flows from a data source through a data source connector to a Kafka topic. And how data flows from a Kafka topic to a data sink through a data sink connector.
116
-
117
-
[.screencapture]
118
-
.{product-long-connectors} data flow
119
-
image::connectors-diagram.png[Illustration of data flow from data source through Kafka to data sink]
After you create a {product-kafka} instance, configure by performing the following tasks:
115
+
In this task, you'll create a new topic in your Kafka instance. You'll use this topic in later tasks to produce and consume messages.
128
116
129
-
* Create *Kafka topics* to store messages sent by you and make them available to consumers.
130
-
131
-
For this example, you create one Kafka topic, named *test-topic* which will be used for all commands in the following examples.
132
-
133
-
ifdef::qs[]
134
117
.Prerequisites
135
-
* You've created a {product-kafka} instance and the instance is in the *Ready* state.
136
-
endif::[]
118
+
* You've created a Kafka instance in {product-long-kafka} and the instance is in the *Ready* state.
137
119
138
120
.Procedure
139
-
. Create a Kafka topic for your kafka instance:
140
-
.. In the OpenShift Application Services web console, select *Streams for Apache Kafka* > *Kafka Instances*.
141
-
.. Click the name of the {product-kafka} instance that you created.
142
-
.. Select the *Topics* tab, and then click *Create topic*.
143
-
.. Type a unique name for your topic. For example, type *test-topic* for *Topic Name*.
144
-
.. Accept the default settings for message retention, and replicas. But set the partition count to *2*.
121
+
. On the {service-url-kafka}[Kafka Instances^] page of the {product-kafka} web console, click the Kafka instance that you want to add a topic to.
122
+
. Select the *Topics* tab.
123
+
. Click *Create topic* and follow the guided steps to define the topic details.
124
+
+
125
+
You must specify the following topic properties:
126
+
127
+
* *Topic name*: For this quick start, enter `test-topic` as the topic name.
128
+
* *Partitions*: Set the number of partitions for the topic. For this quick start, set the value to `2`.
129
+
* *Message retention*: Set the message retention time and size. For this quick start, set the retention time to `A week` and the retention size to `Unlimited`.
130
+
* *Replicas*: For this release of {product-kafka}, replica values are preconfigured. The number of partition replicas and the minimum number of follower replicas that must be in sync with a partition leader are both set to `1`.
131
+
+
132
+
After you complete the setup, the new topic appears on the *Topics* page.
145
133
146
-
ifdef::qs[]
147
134
.Verification
148
-
* Did you create a topic for the kafka instance?
135
+
ifdef::qs[]
136
+
* Does `test-topic` appear on the *Topics* page?
137
+
endif::[]
138
+
ifndef::qs[]
139
+
* Verify that `test-topic` appears on the *Topics* page.
149
140
endif::[]
150
141
151
-
152
-
[id="proc-produce-message_{context}"]
153
-
== Producing a message to a {product-kafka} instance
142
+
[id="proc-producing-messages_{context}"]
143
+
== Producing messages to your Kafka instance
154
144
155
145
[role="_abstract"]
156
-
You can produce your own message from the Cli instead of using an application. This is very useful for testing and debuging your {product-kafka} instance.
146
+
When you have a Kafka instance with a topic, you're ready to use the CLI to produce messages. In this task, you'll produce four messages to your Kafka instance.
157
147
158
148
.Prerequisites
159
-
. You're logged in to the OpenShift Application Services web console at {service-url-connectors}[^].
160
-
. You configured a {product-kafka} instance for connectors as described _Configuring the {product-kafka} instance for use with {product-long-connectors}_.
161
-
. You are logged into the Rhoas Cli with your OpenShift Application Services account using `rhoas login`.
149
+
* You've created `test-topic` on your Kafka instance.
162
150
163
151
.Procedure
164
-
. To produce a message to your kafka topic use the following command `rhoas kafka topic produce --name=test-topic` and enter a value when prompted, for example enter `Hello world!`.
165
-
166
-
. Read the message
167
-
.. In the OpenShift Application Services web console, select *Streams for Apache Kafka* > *Kafka Instances*.
168
-
.. Click the name of the {product-kafka} instance that you created.
169
-
.. Select the *Topics* tab, and then click the name of your topic.
170
-
.. Select the *Messages* tab, and see the message you create from the Rhoas Cli
171
-
172
-
. By default any message you create is sent to the *0* partition. To create a message for the *1* partition run the following and enter another value `rhoas kafka topic produce --name=test-topic --partition=0`.
173
-
174
-
. Go back to the messages tab in the topic and see if your message is now on a different partition.
152
+
. Log in to the `rhoas` CLI.
153
+
+
154
+
[source]
155
+
----
156
+
$ rhoas login
157
+
----
158
+
159
+
. Specify the Kafka instance that you want to produce messages to.
160
+
+
161
+
[source,subs="+quotes"]
162
+
----
163
+
$ rhoas kafka use --name=_<my-kafka-instance>_
164
+
----
165
+
166
+
. Produce your first message to `test-topic`.
167
+
+
168
+
[source]
169
+
----
170
+
rhoas kafka topic produce --name=test-topic
171
+
----
172
+
+
173
+
You're prompted to enter a message value.
174
+
175
+
. Enter `First message` as the message value.
176
+
177
+
. Repeat the previous steps to produce your second and third messages to `test-topic`. Enter `Second message` and `Third message` as the message values.
178
+
179
+
. Produce your fourth and final message to `test-topic`. This time, specify a partition value of `1` and a custom message key. An example is shown below.
180
+
+
181
+
[source]
182
+
----
183
+
rhoas kafka topic produce --name=test-topic --partition=1 --key="{'location': 'us-east-1'}"
184
+
----
185
+
186
+
. Enter `Fourth message` as the value of the final message.
187
+
188
+
. To view the messages in the {product-long-kafka} {service-url-kafka}[web console^], perform the following actions:
189
+
.. On the *Kafka Instances* page, click the name of your Kafka instance.
190
+
.. Select the *Topics* tab, and then click `test-topic`.
191
+
.. Select the *Messages* tab.
192
+
+
193
+
The messages table shows the messages you produced.
194
+
.. Observe the following details about the messages you produced:
195
+
+
196
+
* Because you didn't specify a partition value when producing the first three messages, these messages all went to partition `0` by default.
197
+
* The three messages on partition `0` have offset values of `0`, `1`, and `2`.
198
+
* The final message is on partition `1` and has the custom key value that you specified.
175
199
176
200
.Verification
177
-
* Does running the commands produce messages?
178
-
179
-
.. In the OpenShift Application Services web console, select *Streams for Apache Kafka* > *Kafka Instances*.
180
-
.. Click the Kafka instance that you created.
181
-
.. Click the *Topics* tab and then click the topic that you specified for your {product-kafka} instance.
182
-
.. Click the *Messages* tab to see a `Hello World!` message.
183
-
201
+
ifdef::qs[]
202
+
* Does the messages table show the four messages that you produced?
203
+
endif::[]
204
+
ifndef::qs[]
205
+
* Verify that the messages table shows the four messages you produced.
206
+
endif::[]
184
207
185
-
[id="proc-consume-message_{context}"]
186
-
== Consuming messages from a {product-kafka} instance
208
+
[id="proc-consuming-messages_{context}"]
209
+
== Consuming messages from your Kafka instance
187
210
[role="_abstract"]
188
-
You can consume your own message from the Cli instead of using an application. This is very useful for testing and debuging your {product-kafka} instance.
211
+
When you've produced messages to your Kafka instance and verified them using the {product-long-kafka} web console, you're ready to consume the messages. In this task, you'll use the CLI to consume the messages.
189
212
190
213
.Prerequisites
191
-
. You're logged in to the OpenShift Application Services web console at {service-url-connectors}[^].
192
-
. You configured a {product-kafka} instance for connectors as described _Configuring the {product-kafka} instance for use with {product-long-connectors}_.
193
-
. You are logged into the Rhoas Cli with your OpenShift Application Services account using `rhoas login`.
214
+
* You've produced messages to `test-topic` in your Kafka instance.
215
+
* You're logged in to the `rhoas` CLI.
194
216
195
217
.Procedure
196
-
. To consume a message to your kafka topic use the following command `rhoas kafka topic consume --name=test-topic`. You will now see all messages you produced to the topic.
197
-
. Just like produce set the `--partition` flag to consume from a specific partition. Run `rhoas kafka topic consume --name=test-topic --partition=1`. You will now see all messages you produced to the topic on the *1* partition.
218
+
. Specify the Kafka instance that you want to consume messages from.
219
+
+
220
+
[source,subs="+quotes"]
221
+
----
222
+
$ rhoas kafka use --name=_<my-kafka-instance>_
223
+
----
224
+
225
+
. Consume the messages on partition `0` of `test-topic`.
- You've created a Kafka instance and the instance is in `Ready` state. See the _Getting started with OpenShift Streams for Apache Kafka_ quick start.
18
+
- You have a Red Hat identity
19
+
- You've created a Kafka instance and the instance is in the `Ready` state. See the _Getting started with OpenShift Streams for Apache Kafka_ quick start.
20
+
- You've installed the latest version of the rhoas CLI. See <a href="https://access.redhat.com/documentation/en-us/red_hat_openshift_application_services/1/guide/bb30ee92-9e0a-4fd6-a67f-aed8910d7da3">Installing and configuring the rhoas CLI</a>.
0 commit comments