Developers building apps with the Spring Cloud Stream framework can now connect their microservices to the Solace PubSub+ event broker and take advantage of easy, full-featured messaging-based integration with other applications, cloud services and connected devices.

Events are becoming the backbone of today’s modern microservices interactions. Message exchange patterns such as publish/subscribe and event streaming offer many advantages over the API-centric request/response model, such as the ability to decouple services and independently scale services as usage increases and decreases. Each of these advantages provide tangible business value in the form of greater agility, faster time to market, and a more rich and responsive user experience.

Pivotal recently introduced Spring Cloud Stream, a new event-driven framework designed to make it easier to write message-based microservices.

In their own words:

“Spring Cloud Stream is a framework for building highly scalable event-driven microservices connected with shared messaging systems. The framework 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.”

Spring Cloud Stream builds on the “opinionated configuration” approach of other Spring frameworks (like Spring Boot) to abstract the nuances of messaging middleware away from the application developer and allow them to focus on the business logic of their microservice. Developers no longer need to learn event broker client APIs, protocols or the complex semantics of asynchronous communication.

Spring Cloud Stream presents a declarative, annotation-based interface that is standardized across vendor broker implementations.

An image demonstrate Spring Cloud Stream MicroService

Increasingly, the challenge of having complex event/data integration is reducing developer productivity. These developers are using modern frameworks such as Spring Cloud Stream to accelerate the development of event-driven microservices, but that efficiency is hindered by the inability to access events flowing out of legacy systems, systems of record or streaming from mobile/IoT devices.

Developers frequently face challenges even when simply trying to exchange events across organizational boundaries. All these new, greenfield microservices are producing events and insights that in many cases must be consumed by non-Spring Cloud Stream applications in a variety of ways (such as streaming, queueing and replay).

What these organizations really need is an architectural layer known as an event mesh.

An event mesh gives enterprises the ability to support event-driven architectures, from the smallest of microservices deployments to extending applications to hybrid cloud in a governed, performant, robust, secure, well-architected manner. It provides the ability to integrate legacy applications, modern microservices, devices, data stores, SaaS – dynamically and in real-time.

An event mesh gives application developers and architects a foundation on which to build and deploy distributed, event-driven applications wherever they need to be built and deployed.

Solace PubSub+ event brokers are uniquely capable of helping organizations create an event mesh and, when combined with Pivotal’s Spring framework, are a great way for developers to create production-grade, reactive microservices that can consume any event from anywhere, even across long-distance WAN links and organizational boundaries.

Spring Cloud Stream allows developers to define the specifics of the event broker in configuration (such as broker host/port and credentials/certificates) and simply “bind” to the middleware using Spring annotations.

You can find examples of using the Solace PubSub+ Spring Cloud Stream binder in our samples repository. These samples are a subset of the Spring Cloud Steam samples and focus on the Solace PubSub+ configuration and basic functionality.

Microservices are either Sources, Sinks or Processor and specify the destination of the events in which they intend to consume from and/or produce to. Uniquely to Solace, these destinations and their corresponding events can be produced to one part of the mesh (i.e., onto one event broker or Pivotal Platform service instance) and can be consumed by applications/microservices connected to some other part of the mesh (i.e., a different broker).

Modern applications are extremely dynamic, as microservices are increasingly transient. Businesses may initially be running an application on-premises, but due to changes in utilization may need to deploy it into the cloud (e.g., cloud bursting). The Solace-provided capability of dynamic, intelligent routing is critical to enable both business agility and overall time to market.

Let’s look at an example of a Spring Cloud Stream app:

@SpringBootApplication
@EnableBinding(Sink.class)
public class LoggingConsumerApplication {

	public static void main(String[] args) {
		SpringApplication.run(LoggingConsumerApplication.class, args);
	}

	@StreamListener(Sink.INPUT)
	public void handle(Person person) {
		System.out.println("Received: " + person);
	}

	public static class Person {
		private String name;
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public String toString() {
			return this.name;
		}
	}
}

From an event broker point of view, Spring has defined a “binder” interface with standard service provider interfaces (SPIs) across all the binder implementations that do the work of connecting to brokers “under the covers.” This ensures that Spring Cloud Stream applications are event broker agnostic: they behave the same across broker vendors and versions, and don’t lock you in to any one broker.

The highlighted code above shows how messaging-specific annotations can be used to bind an application to a binder (in the @EnableBinding annotation) and receive messages from a channel (in the @StreamListener annotation). Behind the scenes, Spring Cloud Stream will invoke the correct binder classes to execute the requested actions. Developers can easily invoke a different binder or use a different input/output channel simply by changing the binder configuration.

Solace has fully embraced the Spring Cloud Stream approach and released a Spring Cloud Stream binder that lets applications leverage the high performance and flexibility of topics, queues and a wealth of other event routing capabilities on Solace PubSub+ software and hardware brokers. The binder is open source and is available on GitHub as well as Maven Central for adding as a dependency to Spring Boot applications.

We have also developed some Spring Cloud sample applications which you can download and experiment with.

Thanks to our strong partnership with Pivotal (we recently won their 2018 “Do The Right Thing” Award), we’re one of the first vendors to release a Spring Cloud Stream binder. We’re excited to see what applications our customers can build using Spring Cloud Stream, as well as Spring Cloud Data Flow, a powerful toolkit for creating rich data integration and real-time data processing pipelines.

Streams can be easily constructed using either a GUI designer or a DSL which is based on a UNIX-like, pipeline syntax.

Get started with the Solace Spring Cloud Stream Binder and PubSub+ Event Broker to unleash the power of your reactive streams and microservices!


a video interviewing Product manager– Darryl MacRae and Andrew Mackenzie

Andrew MacKenzie

Andrew is a Product Manager at Solace, mainly focusing on data movement to/from the PubSub+ Platform with connectors and APIs. Andrew brings over 25 years of enterprise software industry experience in business intelligence, digital content protection and supply chain analytics. Outside of work, Andrew is a fan of all things cycling (road, mountain biking, BMX), an avid PC gamer and a hobby developer who contributes to various open source software projects.