Improve Java DSL for Rabbit Streams (#8598)

* Improve Java DSL for Rabbit Streams

* Expose simple properties for `streamName` and `superStream`
on the `RabbitStreamInboundChannelAdapterSpec`
* Add `superStream(String superStream, String name, int consumers)` option
* Add `outboundStreamAdapter(Environment environment, String streamName)` factory for
simple use-cases
* Add `RabbitStreamTests` integration test to cover Rabbit Streams support
 and demonstrate respective Java DSL
* Mention the change in the docs

* * Fix typos in code and docs
This commit is contained in:
Artem Bilan
2023-04-18 10:16:19 -04:00
committed by GitHub
parent fa178c3da6
commit feb4705e79
6 changed files with 260 additions and 30 deletions

View File

@@ -1426,7 +1426,7 @@ image::images/spring-integration-amqp-sample-graph.png[align="center"]
Version 6.0 introduced support for RabbitMQ Stream Queues.
The DSL factory class for these endpoints is `Rabbit`.
The DSL factory class for these endpoints is `RabbitStream`.
[[rmq-stream-inbound-channel-adapter]]
==== RabbitMQ Stream Inbound Channel Adapter
@@ -1435,22 +1435,17 @@ The DSL factory class for these endpoints is `Rabbit`.
[source, java]
----
@Bean
IntegrationFlow flow(Environment env) {
@Bean
IntegrationFlow simpleStream(Environment env) {
return IntegrationFlow.from(RabbitStream.inboundAdapter(env)
.configureContainer(container -> container.queueName("my.stream")))
// ...
.get();
}
IntegrationFlow simpleStream(Environment env) {
return IntegrationFlow.from(RabbitStream.inboundAdapter(env).streamName("my.stream"))
// ...
.get();
}
@Bean
IntegrationFlow superStream(Environment env) {
return IntegrationFlow.from(RabbitStream.inboundAdapter(env)
.configureContainer(container -> container.superStream("my.stream", "my.consumer")))
// ...
.get();
}
@Bean
IntegrationFlow superStream(Environment env) {
return IntegrationFlow.from(RabbitStream.inboundAdapter(env).superStream("my.super.stream", "my.consumer"))
// ...
.get();
}
----
====
@@ -1462,10 +1457,10 @@ IntegrationFlow flow(Environment env) {
[source, java]
----
@Bean
IntegrationFlow outbound(RabbitStreamTemplate template) {
IntegrationFlow outbound(Environment env) {
return f -> f
// ...
.handle(RabbitStream.outboundStreamAdapter(template));
.handle(RabbitStream.outboundStreamAdapter(env, "my.stream"));
}
----

View File

@@ -69,3 +69,9 @@ See <<./mail.adoc#mail-inbound, Mail-receiving Channel Adapter>> for more inform
The `FileReadingMessageSource` now exposes `watchMaxDepth` and `watchDirPredicate` options for the `WatchService`.
See <<./file.adoc#watch-service-directory-scanner, `WatchServiceDirectoryScanner`>> for more information.
[[x6.1-amqp]]
=== AMQP Changes
The Java DSL API for Rabbit Streams (the `RabbitStream` factory) exposes additional properties for simple configurations.
See <<./amqp.adoc#rmq-streams, `RabbitMQ Stream Queue Support`>> for more information.