Azure Event Grid Publish/Consume Samples for Java
This contains Java samples for publishing events to Azure Event Grid and consuming events from Azure Event Grid. It also contains a set of management samples that demonstrates how to manage topics and event subscriptions using Java code.
Features
These samples demonstrate the following features:
- How to create an event grid topic using Java.
- How to create an event subscription to a topic using Java.
- How to create an event hub using Java.
- How to publish events to Azure Event Grid using Java.
- How to consume events delivered by Azure Event Grid through an Azure Event Hub consumer using Java.
Getting started
Getting started explained in detail here. Please refer it to add dependency and configure authentication environment variables.
For details on including this dependency in other build tools (Gradle, SBT, etc), refer here.
Sample details
Azure event grid publish and consume sample code is here. It has the main() function and can be run directly.
The sample demonstrates following operations:
- Create a resource group.
- Create an event hub.
- Create an event grid topic.
- Create an event grid subscription.
- Retrieve the event grid client connection key.
- Create an event grid publisher client:
EventGridPublisherClient. - Create an event hub consumer client:
EventHubConsumerAsyncClient. - Subscribe to coming events from event grid using
EventHubConsumerAsyncClient. - Publish custom events to the event grid using
EventGridPublisherClient. - Clean up the resources created above.
Key concepts
Key concepts are explained in detail here.
Next steps
Start using Event Grid Java SDK in your solutions. Our SDK details could be found at SDK README.
For more information about other Azure Management SDK, refer here.
Contributing
This project welcomes contributions and suggestions. Find more contributing details here.
More information
If you don't have a Microsoft Azure subscription you can get a FREE trial account here