Skip to content

Spring cloud stream guide #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix bullet attempt
  • Loading branch information
Mrc0113 committed Sep 20, 2019
commit 4a69448a02c817e557247d933bed79a66fb7e103
9 changes: 9 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ This class shows how simple it is to write a Spring Cloud Streams app that consu
Copy the code below in place of the "//TODO - INSERT CODE HERE" comment.

A few things to take note of:

* The @SpringBootApplication annotation enables auto-configuration and component scanning
* The @EnableBinding(Sink.class) annotation tells us that we are creating a Spring Cloud Streams Sink application and enables the Input channel on the Sink binding interface. This Sink's input channel will connect to our messaging system at run time.
* The @StreamListener annotation defines which method should be invoked when an event is received on our Sink.INPUT channel.
Expand Down Expand Up @@ -118,6 +119,7 @@ Next let's take a look at the application.yml file. Note that an application.pro
Open the application.yml file in the "initial/cloud-streams-sink" project.

A few things to take note of:

* The spring.cloud.stream.bindings.input maps to the Sink.INPUT channel for our application.
* Because a "group" is specified we are following the Spring Cloud Streams "Consumer Group" pattern; if a group was not specified the app would be using the Publish-Subscribe pattern.
* Spring Cloud Streams will use the "local_solace" binder since it's the only one present; if multiple binders are present you can specify the binder on each binding.
Expand Down Expand Up @@ -172,6 +174,7 @@ The class is simulating an event source that emits a temperature, in Fahrenheit,
Copy the code below in place of the "//TODO - INSERT CODE HERE" comment.

A few things to take note of:

* As before the @SpringBootApplication annotation enables auto-configuration and component scanning
* The @EnableBinding(Source.class) annotation tells us that we are creating a Spring Cloud Streams Source application and enables the Output channel on the Source binding interface. This Source's output channel will connect to our messaging system at run time.
* The @InboundChannelAdapter annotation defines which method will be using the Source.OUTPUT channel. It is also enabling us to send a SensorReading event every 5 seconds.
Expand Down Expand Up @@ -211,6 +214,7 @@ Next let's take a look at the application.yml file. As stated earlier, an applic
Open the application.yml file in the "initial/cloud-streams-source" project.

A few things to take note of:

* The spring.cloud.stream.bindings.output maps to the Source.OUTPUT channel for our application; in this example we are sending to the "sensor/temperature/fahrenheit" topic.
* Spring Cloud Streams will use the "local_solace" binder since it's the only one present; if multiple binders are present you can specify the binder on each binding.
* Change your *host*, *msgVpn*, *clientUsername* & *clientPassword* to match your Solace Messaging Service. The host should be your "SMF URI".
Expand Down Expand Up @@ -261,6 +265,7 @@ The class is a processor which receives SensorReadings in Fahrenheit from one to
Copy the code below in place of the "//TODO - INSERT CODE HERE" comment.

A few things to take note of:

* As before the [@SpringBootApplication](https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-using-springbootapplication-annotation.html) annotation enables auto-configuration and component scanning
* The @EnableBinding(Processor.class) annotation tells us that we are creating a Spring Cloud Streams Processor application and enables the Input & Output channels on the Processor binding interface. This Prcoessor's input & output channels will be bound to our messaging system at run time.
* The @StreamListener annotation defines which method should be invoked when an event is received on our Processor.INPUT channel.
Expand Down Expand Up @@ -298,6 +303,7 @@ Next let's take a look at the application.yml file. As stated earlier, an applic
Open the application.yml file in the "initial/cloud-streams-processor" project.

A few things to take note of:

* The spring.cloud.stream.bindings now includes both an "input" and an "output" binding. These maps to our Processor.INPUT & Processor.OUTPUT channels respectively; note that our output destination will be sending to the "sensor/temperature/celsius" topic.
* Spring Cloud Streams will use the "local_solace" binder since it's the only one present; if multiple binders are present you can specify the binder on each binding.
* Change your *host*, *msgVpn*, *clientUsername* & *clientPassword* to match your Solace Messaging Service. The host should be your "SMF URI".
Expand Down Expand Up @@ -356,8 +362,11 @@ Hopefully you found that Spring Cloud Stream makes it super simple to develop ev
== See Also

You can learn more in the Spring Cloud Stream Reference Guide:

* https://docs.spring.io/spring-cloud-stream/docs/current/reference/htmlsingle/ [ Spring Cloud Stream Reference Guide ]

Questions about Solace PubSub+ ?

* https://solace.community [ Join the Solace Developer Community]

include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/footer.adoc[]