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
@@ -4,28 +4,133 @@ As pushing the application into IBM Cloud® does not require you to build the ap
4
4
We will not discuss establishing a connection from your laptop to Event Streams for IBM Cloud. This is described in the [connection guide](https://cloud.ibm.com/docs/services/EventStreams?topic=eventstreams-connecting#connecting).
5
5
6
6
## Prerequisites
7
-
* Provision an [Event Streams Service Instance](https://cloud.ibm.com/catalog/services/event-streams) in [IBM Cloud®](https://cloud.ibm.com/)
8
-
* Install [Gradle 4+](https://gradle.org/)
9
-
* Install Java 7+
10
7
11
-
## Build the Sample
12
-
Build the project using gradle:
13
-
```shell
14
-
gradle clean build
15
-
```
8
+
1.**If you don't already have one, create an Event Streams service instance.**
16
9
17
-
The command above creates a jar file under `build/libs`.
10
+
1. Log in to the IBM Cloud console.
11
+
12
+
2. Click **Catalog**.
13
+
14
+
3. From the navigation pane, click **Integration**, click the **Event Streams** tile, and then select the **Lite plan**. The Event Streams service instance page opens.
15
+
16
+
4. Enter a name for your service. You can use the default value.
17
+
18
+
5. Click **Create**. The Event Streams **Getting started** page opens.
18
19
19
-
## Running the Sample
20
-
Once built, to run the sample, execute the following command:
2.**If you don't already have them, install the following prerequisites:**
21
+
22
+
* [git](https://git-scm.com/)
23
+
* [Gradle](https://gradle.org/)
24
+
* Java 8 or higher
24
25
25
-
To find the values for `<kafka_brokers_sasl>` and `<api_key>`, access your Event Streams instance in IBM Cloud®, go to the `Service Credentials` tab and select the `Credentials` you want to use.
26
26
27
-
__Note__: `<kafka_brokers_sasl>` must be a single string enclosed in quotes. For example: `"host1:port1,host2:port2"`. We recommend using all the Kafka hosts listed in the `Credentials` you selected.
28
27
29
-
Alternatively, you can run only the producer or only the consumer by respectively appending the switches `-producer` or `-consumer` to the command above.
28
+
## Steps to Build the Sample
30
29
31
-
The sample will run indefinitely until interrupted. To stop the process, use `Ctrl+C`.
30
+
### 1. **Create a topic**
31
+
32
+
The topic is the core of Event Streams flows. Data passes through a topic from producing applications to consuming applications.
33
+
34
+
We'll be using the IBM Cloud console (UI) to create the topic, and will reference it when starting the application.
35
+
36
+
1. Go to the **Topics** tab.
37
+
38
+
2. Click **New topic**.
39
+
40
+
3. Name your topic.
41
+
42
+
> The sample application is configured to connect to topic `kafka-java-console-sample-topic`. If the topic does not exist, it is created when the application is started.
43
+
44
+
4. Keep the defaults set in the rest of the topic creation, click **Next** and then **Create topic**.
45
+
46
+
5. The topic appears in the table. Congratulations, you have created a topic!
47
+
48
+
---
49
+
50
+
### 2. **Create credentials**
51
+
52
+
To allow the sample application to access your topic, we need to create some credentials for it.
53
+
54
+
1. Go to **Service credentials** in the navigation pane.
55
+
56
+
2. Click **New credential**.
57
+
58
+
3. Give the credential a name so you can identify its purpose later. You can accept the default value.
59
+
60
+
4. Give the credential the **Manager** role so that it can access the topics, and create them if necessary.
61
+
62
+
5. Click **Add**. The new credential is listed in the table in **Service credentials**.
63
+
64
+
6. Click **View credentials** to see the `api_key` and `kafka_brokers_sasl` values.
65
+
66
+
---
67
+
68
+
### 3. **Clone the Github repository for the sample application**
69
+
70
+
The sample application is stored here. Clone the `event-streams-samples` repository by running the clone command from the command line.
When the repository is cloned, from the command line change into the <code>kafka-java-console-sample</code> directory.
78
+
79
+
```
80
+
cd event-streams-samples/kafka-java-console-sample
81
+
```
82
+
83
+
<br/>
84
+
Build the contents of the <code>kafka-java-console-sample</code> directory.
85
+
86
+
```
87
+
gradle clean && gradle build
88
+
```
89
+
---
90
+
91
+
### 4. **Run the consuming application**
92
+
93
+
Start the sample consuming application from the command line, replacing the `kafka_brokers_sasl` and `api_key` values.
94
+
95
+
The `java -jar ./build/libs/kafka-java-console-sample-2.0.jar` part of the command identifies the locations of the .JAR file to run within the cloned repository. You do not need to change this.
96
+
97
+
Use the `kafka_brokers_sasl` from the **Service credentials** created in Step 2. We recommend using all the `kafka_brokers_sasl` listed in the **Service credentials** that you created.
98
+
99
+
>The `kafka_brokers_sasl` must be formatted as `"host:port,host2:port2"`. </br> Format the contents of `kafka_brokers_sasl` in a text editor before entering it in the command line.
100
+
101
+
Then, use the `api_key` from the **Service credentials** created in Step 2. `-consumer` specifies that the consumer should start.
An `INFO No messages consumed` is displayed when the consuming application is running, but there is no data being consumed.
109
+
110
+
---
111
+
112
+
### 5. **Run the producing application**
113
+
114
+
Open a new command line window and change into the <code>kafka-java-console-sample</code> directory.
115
+
116
+
```
117
+
cd event-streams-samples/kafka-java-console-sample
118
+
```
119
+
120
+
Then, start the sample producing application from the command line, replacing the `kafka_brokers_sasl` and `api_key` values with the same ones used to run the consumer.
121
+
122
+
Use the `api_key` from the **Service credentials** created in Step 2. `-producer` specifies that the producer should start.
0 commit comments