|
2 | 2 | title: 'Quickstart: Data streaming with Azure Event Hubs using the Kafka protocol'
|
3 | 3 | description: 'Quickstart: This article provides information on how to stream into Azure Event Hubs using the Kafka protocol and APIs.'
|
4 | 4 | ms.topic: quickstart
|
5 |
| -ms.date: 09/26/2022 |
| 5 | +ms.date: 11/02/2022 |
6 | 6 | ms.custom: mode-other
|
7 | 7 | ---
|
8 | 8 |
|
@@ -33,6 +33,55 @@ When you create an Event Hubs namespace, the Kafka endpoint for the namespace is
|
33 | 33 |
|
34 | 34 | ## Send and receive messages with Kafka in Event Hubs
|
35 | 35 |
|
| 36 | + |
| 37 | +### [Connection string](#tab/connection-string) |
| 38 | + |
| 39 | +1. Clone the [Azure Event Hubs for Kafka repository](https://github.com/Azure/azure-event-hubs-for-kafka). |
| 40 | + |
| 41 | +1. Navigate to *azure-event-hubs-for-kafka/quickstart/java/producer*. |
| 42 | + |
| 43 | +1. Update the configuration details for the producer in *src/main/resources/producer.config* as follows: |
| 44 | + |
| 45 | + ```xml |
| 46 | + bootstrap.servers=NAMESPACENAME.servicebus.windows.net:9093 |
| 47 | + security.protocol=SASL_SSL |
| 48 | + sasl.mechanism=PLAIN |
| 49 | + sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="{YOUR.EVENTHUBS.CONNECTION.STRING}"; |
| 50 | + ``` |
| 51 | + |
| 52 | + > [!IMPORTANT] |
| 53 | + > Replace `{YOUR.EVENTHUBS.CONNECTION.STRING}` with the connection string for your Event Hubs namespace. For instructions on getting the connection string, see [Get an Event Hubs connection string](event-hubs-get-connection-string.md). Here's an example configuration: `sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="Endpoint=sb://mynamespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=XXXXXXXXXXXXXXXX";` |
| 54 | +
|
| 55 | +1. Run the producer code and stream events into Event Hubs: |
| 56 | + |
| 57 | + ```shell |
| 58 | + mvn clean package |
| 59 | + mvn exec:java -Dexec.mainClass="TestProducer" |
| 60 | + ``` |
| 61 | + |
| 62 | +1. Navigate to *azure-event-hubs-for-kafka/quickstart/java/consumer*. |
| 63 | + |
| 64 | +1. Update the configuration details for the consumer in *src/main/resources/consumer.config* as follows: |
| 65 | + |
| 66 | + ```xml |
| 67 | + bootstrap.servers=NAMESPACENAME.servicebus.windows.net:9093 |
| 68 | + security.protocol=SASL_SSL |
| 69 | + sasl.mechanism=PLAIN |
| 70 | + sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="{YOUR.EVENTHUBS.CONNECTION.STRING}"; |
| 71 | + ``` |
| 72 | + |
| 73 | + > [!IMPORTANT] |
| 74 | + > Replace `{YOUR.EVENTHUBS.CONNECTION.STRING}` with the connection string for your Event Hubs namespace. For instructions on getting the connection string, see [Get an Event Hubs connection string](event-hubs-get-connection-string.md). Here's an example configuration: `sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="Endpoint=sb://mynamespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=XXXXXXXXXXXXXXXX";` |
| 75 | +
|
| 76 | +1. Run the consumer code and process events from event hub using your Kafka clients: |
| 77 | + |
| 78 | + ```java |
| 79 | + mvn clean package |
| 80 | + mvn exec:java -Dexec.mainClass="TestConsumer" |
| 81 | + ``` |
| 82 | + |
| 83 | +If your Event Hubs Kafka cluster has events, you'll now start receiving them from the consumer. |
| 84 | + |
36 | 85 | ### [Passwordless (Recommended)](#tab/passwordless)
|
37 | 86 | 1. Enable a system-assigned managed identity for the virtual machine. For more information about configuring managed identity on a VM, see [Configure managed identities for Azure resources on a VM using the Azure portal](../active-directory/managed-identities-azure-resources/qs-configure-portal-windows-vm.md#system-assigned-managed-identity). Managed identities for Azure resources provide Azure services with an automatically managed identity in Azure Active Directory. You can use this identity to authenticate to any service that supports Azure AD authentication, without having credentials in your code.
|
38 | 87 |
|
@@ -92,54 +141,6 @@ Azure Event Hubs supports using Azure Active Directory (Azure AD) to authorize r
|
92 | 141 |
|
93 | 142 | :::image type="content" source="./media/event-hubs-quickstart-kafka-enabled-event-hubs/producer-consumer-output.png" alt-text="Screenshot showing the Producer and Consumer app windows showing the events.":::
|
94 | 143 |
|
95 |
| -### [Connection string](#tab/connection-string) |
96 |
| - |
97 |
| -1. Clone the [Azure Event Hubs for Kafka repository](https://github.com/Azure/azure-event-hubs-for-kafka). |
98 |
| - |
99 |
| -1. Navigate to *azure-event-hubs-for-kafka/quickstart/java/producer*. |
100 |
| - |
101 |
| -1. Update the configuration details for the producer in *src/main/resources/producer.config* as follows: |
102 |
| - |
103 |
| - ```xml |
104 |
| - bootstrap.servers=NAMESPACENAME.servicebus.windows.net:9093 |
105 |
| - security.protocol=SASL_SSL |
106 |
| - sasl.mechanism=PLAIN |
107 |
| - sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="{YOUR.EVENTHUBS.CONNECTION.STRING}"; |
108 |
| - ``` |
109 |
| - |
110 |
| - > [!IMPORTANT] |
111 |
| - > Replace `{YOUR.EVENTHUBS.CONNECTION.STRING}` with the connection string for your Event Hubs namespace. For instructions on getting the connection string, see [Get an Event Hubs connection string](event-hubs-get-connection-string.md). Here's an example configuration: `sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="Endpoint=sb://mynamespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=XXXXXXXXXXXXXXXX";` |
112 |
| -
|
113 |
| -1. Run the producer code and stream events into Event Hubs: |
114 |
| - |
115 |
| - ```shell |
116 |
| - mvn clean package |
117 |
| - mvn exec:java -Dexec.mainClass="TestProducer" |
118 |
| - ``` |
119 |
| - |
120 |
| -1. Navigate to *azure-event-hubs-for-kafka/quickstart/java/consumer*. |
121 |
| - |
122 |
| -1. Update the configuration details for the consumer in *src/main/resources/consumer.config* as follows: |
123 |
| - |
124 |
| - ```xml |
125 |
| - bootstrap.servers=NAMESPACENAME.servicebus.windows.net:9093 |
126 |
| - security.protocol=SASL_SSL |
127 |
| - sasl.mechanism=PLAIN |
128 |
| - sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="{YOUR.EVENTHUBS.CONNECTION.STRING}"; |
129 |
| - ``` |
130 |
| - |
131 |
| - > [!IMPORTANT] |
132 |
| - > Replace `{YOUR.EVENTHUBS.CONNECTION.STRING}` with the connection string for your Event Hubs namespace. For instructions on getting the connection string, see [Get an Event Hubs connection string](event-hubs-get-connection-string.md). Here's an example configuration: `sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="Endpoint=sb://mynamespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=XXXXXXXXXXXXXXXX";` |
133 |
| -
|
134 |
| -1. Run the consumer code and process events from event hub using your Kafka clients: |
135 |
| - |
136 |
| - ```java |
137 |
| - mvn clean package |
138 |
| - mvn exec:java -Dexec.mainClass="TestConsumer" |
139 |
| - ``` |
140 |
| - |
141 |
| -If your Event Hubs Kafka cluster has events, you will now start receiving them from the consumer. |
142 |
| - |
143 | 144 | ---
|
144 | 145 |
|
145 | 146 | ## Next steps
|
|
0 commit comments