92 lines
2.9 KiB
HTML
92 lines
2.9 KiB
HTML
---
|
|
# The name of your project
|
|
title: Spring Cloud Stream
|
|
|
|
badges:
|
|
|
|
# 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: StackOverflow
|
|
url: http://stackoverflow.com/questions/tagged/spring-cloud
|
|
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 allows a user to develop and run messaging microservices using Spring Integration and run them locally, or in the cloud, or even on Spring XD. Just create `MessageChannels` "input" and/or "output" and add `@EnableChannelBinding` and run your app as a Spring Boot app (single application context). You just need to connect to the physical broker for the bus, which is automatic if the relevant bus implementation is available on the classpath.
|
|
|
|
{% 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 XD Message Bus is on the
|
|
classpath any Spring Boot application with `@EnableChannelBinding` will bind to an external broker provided by the bus (e.g. redis, rabbit, kafka, depending on the implementation you choose). Sample application:
|
|
|
|
```java
|
|
@SpringBootApplication
|
|
@EnableChannelBinding
|
|
@ComponentScan(basePackageClasses=ModuleDefinition.class)
|
|
public class ModuleApplication {
|
|
|
|
public static void main(String[] args) throws InterruptedException {
|
|
SpringApplication.run(ModuleApplication.class, args);
|
|
}
|
|
|
|
}
|
|
|
|
@Configuration
|
|
public class ModuleDefinition {
|
|
|
|
@Value("${format}")
|
|
private String format;
|
|
|
|
@Bean
|
|
public MessageChannel output() {
|
|
return new DirectChannel();
|
|
}
|
|
|
|
@Bean
|
|
@InboundChannelAdapter(value = "output", autoStartup = "false", poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
|
|
public MessageSource<String> timerMessageSource() {
|
|
return () -> new GenericMessage<>(new SimpleDateFormat(format).format(new Date()));
|
|
}
|
|
|
|
}
|
|
```
|
|
|
|
{% endcapture %}
|
|
|
|
{% capture related_resources %}
|
|
|
|
### Sample Projects
|
|
|
|
* [Source](https://github.com/spring-cloud/spring-cloud-stream/tree/master/spring-cloud-stream-samples/source)
|
|
* [Sink](https://github.com/spring-cloud/spring-cloud-stream/tree/master/spring-cloud-stream-samples/sink)
|
|
* [Transformer](https://github.com/spring-cloud/spring-cloud-stream/tree/master/spring-cloud-stream-samples/transformer)
|
|
* [Mashup](https://github.com/spring-cloud/spring-cloud-stream/tree/master/spring-cloud-stream-samples/extended)
|
|
|
|
{% endcapture %}
|
|
|
|
|
|
{% include project_page.html %}
|
|
</html>
|