page_type | languages | products | description | urlFragment | ||
---|---|---|---|---|---|---|
sample |
|
|
Azure Spring Cloud Sample project for Event Hub Integration client library |
azure-spring-integration-eventhubs-sample |
This code sample demonstrates how to use Spring Integration for Azure Event Hub.
Running this sample will be charged by Azure. You can check the usage and bill at this link.
-
Create Azure Event Hubs. Please note
Basic
tier is unsupported. After creating the Azure Event Hub, you can create your own Consumer Group or use the default "$Default" Consumer Group. -
Create Azure Storage for checkpoint use.
-
[Optional] if you want to use service principal, please follow create service principal from Azure CLI to create one.
-
[Optional] if you want to use managed identity, please follow create managed identity to set up managed identity.
-
Update application.yaml. If you choose to use service principal or managed identity, update the
application-sp.yaml
orapplication-mi.yaml
respectively.spring: cloud: azure: eventhub: connection-string: [eventhub-namespace-connection-string] checkpoint-storage-account: [checkpoint-storage-account] checkpoint-access-key: [checkpoint-access-key] checkpoint-container: [checkpoint-container]
-
Update event hub name and consumer group in ReceiveController and SendController.
-
Run the
mvn spring-boot:run
in the root of the code sample to get the app running. -
Send a POST request
$ curl -X POST http://localhost:8080/messages?message=hello
-
Verify in your app’s logs that a similar message was posted:
New message received: 'hello' Message 'hello' successfully checkpointed
-
Delete the resources on Azure Portal to avoid unexpected charges.