![]() Bumps [org.springframework.boot:spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) from 3.4.1 to 3.4.2. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.4.1...v3.4.2) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-parent dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> |
||
---|---|---|
.. | ||
.mvn/wrapper | ||
src/main | ||
mvnw | ||
mvnw.cmd | ||
pom.xml | ||
README.md |
RabbitMQ Stream Tutorial Using Spring AMQP
It is a CLI app that uses Spring Profiles to control its behavior. Each tutorial is a trio of classes: sender, receiver, and configuration.
Prerequisites
To successfully use the examples you will need a running RabbitMQ server with the stream plugin enabled.
See First Application With RabbitMQ Streams, Stream plugin documentation and how to preconfigure plugins.
Usage
These tutorials use Maven. To build them run
./mvnw clean package
The app uses Spring Profiles to control what tutorial it's running, and if it's a Sender or Receiver. Choose which tutorial to run by using these profiles:
- {tut1|hello-world},{sender|receiver}
You can find usage instructions by running the following command:
java -jar target/rabbitmq-stream-tutorials.jar
This will display the following message:
This app uses Spring Profiles to control its behavior.
Options are:
java -jar target/rabbitmq-stream-tutorials.jar --spring.profiles.active=hello-world,receiver
java -jar target/rabbitmq-stream-tutorials.jar --spring.profiles.active=hello-world,sender
Configuration
When running receivers/servers it's useful to set the duration the app runs to a longer time. Do this by setting
the tutorial.client.duration
property.
java -jar target/rabbitmq-stream-tutorials.jar --spring.profiles.active=tut1,receiver,remote --tutorial.client.duration=60000
By default, Spring AMQP uses localhost to connect to RabbitMQ. In the
sample, the remote
profile causes Spring to load the properties in
application-remote.yml
that are used for testing with a non-local
server. Set your own properties in the one in the project, or provide
your own on the command line when you run it.
To use to a remote RabbitMQ installation set the following properties:
spring:
rabbitmq:
host: <rabbitmq-server>
username: <tutorial-user>
password: <tutorial-user>
To use this at runtime create a file called application-remote.yml
(or properties) and set the properties in there. Then set the
remote profile as in the example above. See the Spring Boot
and Spring AMQP documentation for more information on setting application
properties and AMQP properties specifically.