How to create a Spring Cloud Stream Binder from scratch

Domenico Sibilio
5 min readNov 4, 2019

Spring Cloud Stream is a framework built on top of Spring Boot and Spring Integration, that is designed to build event-driven microservices communicating via one or more shared messaging systems.

The core Spring Cloud Stream component is called Binder”, a crucial abstraction that’s already been implemented for the most common messaging systems (eg. Apache Kafka, Kafka Streams, Google PubSub, RabbitMQ, Azure EventHub, Azure ServiceBus…).

In this article, we’ll see in detail how to develop a custom Spring Cloud Stream binder from scratch.

Introduction

The official Spring Cloud Stream documentation already provides a very basic explanation of how to implement your own Spring Cloud Stream binder.

Here’s a brief excerpt from it about the Binder Service Provider Interface that must be implemented in order to create a custom binder:

The Binder SPI consists of a number of interfaces, out-of-the box utility classes, and discovery strategies that provide a pluggable mechanism for connecting to external middleware.

The key point of the SPI is the Binder interface, which is a strategy for connecting inputs and outputs to external middleware. The following listing shows the definition of the Binder

--

--