Skip to main content
Azure
  • 1 min read

Event-driven Java with Spring Cloud Stream Binder for Azure Event Hubs

Spring Cloud Stream Binder for Azure Event Hubs is now generally available. It is simple to build highly scalable event-driven Java apps using Spring Cloud Stream with Event Hubs, a fully managed, real-time data ingestion service on Azure that is resilient and reliable service for any situation.

Spring Cloud Stream Binder for Azure Event Hubs is now generally available. It is simple to build highly scalable event-driven Java apps using Spring Cloud Stream with Event Hubs, a fully managed, real-time data ingestion service on Azure that is resilient and reliable service for any situation. This includes emergencies, thanks to its geo-disaster recovery and geo-replication features.

Spring Cloud Stream provides a binder abstraction for popular message broker implementations. It provides a flexible programming model built on already established and familiar Spring idioms and best practices, including support for persistent pub/sub semantics, consumer groups, and stateful partitions. Now, developers can use the same patterns for building Java apps with Event Hubs.

Azure Event Hubs and Spring Apps graphic

Getting started 

Check out the tutorial, “How to create a Spring Cloud Stream Binder application with Azure Event Hubs,” and build a Java-based Spring Cloud Stream Binder application using the Spring Boot Initializer with Azure Event Hubs. Go to the Azure portal and create a new Event Hubs namespace. Add the following Maven dependency into your Java project. 


     com.microsoft.azure
     spring-cloud-azure-eventhubs-stream-binder
     1.1.0.RC4

Publish messages

Use @EnableBinding(Source.class) to annotate a source class and publish messages to Event Hubs with Spring Cloud Stream patterns. You can customize the output channel for the Source with configurations.

  • Destination: Specify which Event Hub to connect with the output channel.
  • Sync/Async: Specify the mode to produce the messages.

Subscribe to messages 

Use @EnableBinding(Sink.class) to annotate a sink class and consume messages from Event Hubs. You can also customize the input channel with configurations. For the full list, please refer to the documentation, “How to create a Spring Cloud Stream Binder application with Azure Event Hubs.”

  • Destination: Specify an Event Hub to bind with the input channel.
  • Customer Group: Specify a Consumer Group to receive messages.

Try building event-driven Java apps using Spring Cloud Stream Binder for Event Hubs 

Try out a Java app using Spring Cloud Stream Binder on Azure Event Hubs and let us know what you think via email or comments below.

Additional resources