201 lines
7.1 KiB
HTML
201 lines
7.1 KiB
HTML
---
|
|
# The name of your project
|
|
title: Spring Cloud Stream
|
|
|
|
badges:
|
|
|
|
# Specify your project's twitter handle, if any. Delete if none.
|
|
twitter: SpringCloudOSS
|
|
|
|
# Customize your project's badges. Delete any entries that do not apply.
|
|
custom:
|
|
- name: Source (GitHub)
|
|
url: https://github.com/spring-cloud/spring-cloud-stream
|
|
icon: github
|
|
|
|
- name: Issues (Waffle)
|
|
url: https://waffle.io/spring-cloud/spring-cloud-stream
|
|
icon: tracking
|
|
|
|
- name: CI (Jenkins)
|
|
url: https://jenkins.spring.io/view/SpringCloudStream/view/CI/
|
|
icon: ci
|
|
|
|
- name: StackOverflow
|
|
url: http://stackoverflow.com/questions/tagged/spring-cloud-stream
|
|
icon: stackoverflow
|
|
|
|
---
|
|
<!DOCTYPE HTML>
|
|
<html lang="en-US">
|
|
|
|
<!-- Specify the parent of this project (or delete if none) to influence the rendering of the breadcrumb -->
|
|
{% capture parent_link %}
|
|
[Spring Cloud]({{ site.projects_site_url }}/spring-cloud)
|
|
{% endcapture %}
|
|
|
|
|
|
{% capture billboard_description %}
|
|
|
|
Spring Cloud Stream is a framework for building message-driven microservices connected with one another with messaging middleware.
|
|
It builds on Spring Boot provides both connectivity to message brokers as well as programming model for developing
|
|
microservices. Spring Cloud Stream provides an opinionated configuration of message brokers, introducing the concepts of
|
|
persistent pub/sub semantics, consumer groups and partitions across several middleware vendors. This opinionated configuration
|
|
provides the basis to create stream processing applications and is highly customizable.
|
|
|
|
{% endcapture %}
|
|
|
|
{% capture main_content %}
|
|
|
|
<span id="quick-start"></span>
|
|
|
|
## Quick Start
|
|
|
|
<script type="text/javascript">{% include custom.js %}</script>
|
|
{% include download_widget.md %}
|
|
|
|
As long as Spring Cloud Stream and a Spring Cloud Stream Binder dependencies are on the classpath any Spring Boot application with `@EnableBinding` binds to the external
|
|
messaging system (e.g. [Rabbit MQ](https://github.com/spring-cloud/spring-cloud-stream-binder-rabbit) or [Kafka](https://github.com/spring-cloud/spring-cloud-stream-binder-kafka),
|
|
depending on the binder-implementation of choice).
|
|
|
|
For more comprehansive step-by-step _getting started_ experience please refer to the
|
|
[Quick Start](https://docs.spring.io/spring-cloud-stream/docs/Elmhurst.RELEASE/reference/htmlsingle/#_quick_start) section of the user guide, otherwise. . .
|
|
|
|
Below is the fully functional Spring Cloud Stream application, which receives and logs data to the console.
|
|
|
|
```java
|
|
@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;
|
|
}
|
|
}
|
|
}
|
|
```
|
|
As you can see from the preceding example:
|
|
|
|
* We've enabled `Sink` binding (input-no-output) by using `@EnableBinding(Sink.class)`. Doing so signals to the framework to initiate binding to the messaging system,
|
|
where it automatically creates the destination (that is, queue, topic, and others) that are bound to the `Sink.INPUT` channel.
|
|
|
|
* We've added a handler method to receive incoming messages of type `Person`. Doing so lets you see one of the core features of the framework: It tries to automatically convert incoming message
|
|
payloads to type `Person`.
|
|
|
|
You can start the application by simply running its main method.
|
|
|
|
For more details please refer to the [Quick Start](https://docs.spring.io/spring-cloud-stream/docs/Elmhurst.RELEASE/reference/htmlsingle/#_quick_start) section of the user guide.
|
|
|
|
Currently Spring Cloud Stream suports [Rabbit MQ](https://github.com/spring-cloud/spring-cloud-stream-binder-rabbit) and [Kafka](https://github.com/spring-cloud/spring-cloud-stream-binder-kafka) binders with more binder implementations in the pipeline (such as [Google PubSub](https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-pubsub-stream-binder), [AWS Kinesis](https://github.com/spring-cloud/spring-cloud-stream-binder-aws-kinesis) and more).
|
|
|
|
### Kafka Client Compatibility notes
|
|
|
|
Spring Cloud Stream's Kafka binder builds upon Spring Kafka and Spring Integration Kafka libraries. Specifically, Spring Kafka is the core to this foundation, and it is based on the pure java `kafka-clients` jar.
|
|
|
|
The following is the compatibility matrix of Spring cloud Stream and its dependent projects (and broker versions):
|
|
|
|
<table>
|
|
<tr>
|
|
<th>Spring Cloud Stream Version</th>
|
|
<th>Spring for Apache Kafka Version</th>
|
|
<th>Spring Integration for Apache Kafka Version</th>
|
|
<th><code>kafka-clients</code> Version</th>
|
|
<th>Kafka Broker Version</th>
|
|
</tr>
|
|
<tr>
|
|
<td>2.0.x</td>
|
|
<td>2.1.x</td>
|
|
<td>3.0.x</td>
|
|
<td>1.0.x<sup>*</sup></td>
|
|
<td>1.0.x, 0.11.0.x<sup>*</sup></td>
|
|
</tr>
|
|
<tr>
|
|
<td>1.3.x</td>
|
|
<td>1.3.x, 1.2.x, 1.1.x</td>
|
|
<td>2.3.x, 2.2.x, 2.1.x</td>
|
|
<td>0.11.0.x<sup>**</sup>, 0.10.2.x</td>
|
|
<td>(Same as client)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>1.2.x</td>
|
|
<td>1.2.x, 1.1.x</td>
|
|
<td>2.2.x, 2.1.x</td>
|
|
<td>0.10.1.x</td>
|
|
<td>(Same as client)</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Depending on the selected release-combination, the dependent projects will be referenced transitively when using maven or gradle for version management.
|
|
<br/><br/>
|
|
The 2.0.x binder uses the pure java `AdminClient` to provision topics and supports native headers.
|
|
The 1.0.x client can communicate with an 0.11.x.x broker (which also supports headers).
|
|
When using with a 0.11.x.x broker, topics can be provisioned, but the number of partitions cannot be automatically adjusted up.
|
|
To increase the number of topics, you must use the kafka tools instead.
|
|
The property `spring.cloud.stream.kafka.binder.auto-add-partitions` must be `false` (default).
|
|
<br/>
|
|
To use the 0.11.x.x `kafka-clients` with 1.3.x, you must use the `spring-cloud-stream-binder-kafka11` jar (instead of `spring-cloud-stream-binder-kafka`). You must also override certain other jar versions as follows:
|
|
|
|
<table>
|
|
<tr>
|
|
<td>spring-cloud-stream-binder-kafka11</td>
|
|
<td>1.3.0.RELEASE or higher</td>
|
|
</tr>
|
|
<tr>
|
|
<td>spring-kafka</td>
|
|
<td>1.3.2.RELEASE or higher</td>
|
|
</tr>
|
|
<tr>
|
|
<td>spring-integration-kafka</td>
|
|
<td>2.3.0.RELEASE or higher</td>
|
|
</tr>
|
|
<tr>
|
|
<td>spring-integration-core</td>
|
|
<td>4.3.13.RELEASE or higher</td>
|
|
</tr>
|
|
<tr>
|
|
<td>spring-integration-jmx</td>
|
|
<td>4.3.13.RELEASE or higher</td>
|
|
</tr>
|
|
<tr>
|
|
<td>kafka_2.11</td>
|
|
<td>(same version as kafka-clients)</td>
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
{% endcapture %}
|
|
|
|
{% capture related_resources %}
|
|
|
|
### Sample Projects
|
|
|
|
* [Spring Cloud Stream Samples](https://github.com/spring-cloud/spring-cloud-stream-samples)
|
|
|
|
### Related Projects
|
|
|
|
* [Spring Cloud Stream Applications](http://cloud.spring.io/spring-cloud-stream-app-starters/)
|
|
* [Spring Cloud Data Flow](http://cloud.spring.io/spring-cloud-dataflow/)
|
|
|
|
{% endcapture %}
|
|
|
|
|
|
{% include project_page.html %}
|
|
</html>
|