WIP
This commit is contained in:
committed by
Oleg Zhurakousky
parent
b642747781
commit
28f9dcb2a2
@@ -9,7 +9,6 @@ This is particularly useful with a batch listener because you can send multiple
|
||||
To use this technique, set the `useConfirmHeader` property to true
|
||||
The following simple application is an example of using this technique:
|
||||
|
||||
====
|
||||
[source, properties]
|
||||
----
|
||||
spring.cloud.stream.bindings.input-in-0.group=someGroup
|
||||
@@ -25,9 +24,7 @@ spring.cloud.stream.rabbit.bindings.input-in-0.consumer.batch-size=10
|
||||
spring.rabbitmq.publisher-confirm-type=correlated
|
||||
spring.rabbitmq.publisher-returns=true
|
||||
----
|
||||
====
|
||||
|
||||
====
|
||||
[source, java]
|
||||
----
|
||||
@SpringBootApplication
|
||||
@@ -106,7 +103,6 @@ class MyCorrelationData extends CorrelationData {
|
||||
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
As you can see, we send each message and then await for the publication results.
|
||||
If the messages can't be routed, then correlation data is populated with the returned message before the future is completed.
|
||||
|
||||
@@ -10,7 +10,6 @@ Only a single stream queue can be consumed by each binding.
|
||||
To configure the binder to use `containerType=stream`, Spring Boot will automatically configure an `Environment` `@Bean` from the application properties.
|
||||
You can, optionally, add a customizer to customize the listener container.
|
||||
|
||||
====
|
||||
[source, java]
|
||||
----
|
||||
@Bean
|
||||
@@ -24,7 +23,6 @@ ListenerContainerCustomizer<MessageListenerContainer> customizer() {
|
||||
};
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
The `name` argument passed to the customizer is `destination + '.' + group + '.container'`.
|
||||
|
||||
@@ -32,7 +30,6 @@ The stream `name()` (for the purpose of offset tracking) is set to the binding `
|
||||
It can be changed using a `ConsumerCustomizer` shown above.
|
||||
If you decide to use manual offset tracking, the `Context` is available as a message header:
|
||||
|
||||
====
|
||||
[source, java]
|
||||
----
|
||||
int count;
|
||||
@@ -48,7 +45,6 @@ public Consumer<Message<?>> input() {
|
||||
};
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
Refer to the https://rabbitmq.github.io/rabbitmq-stream-java-client/stable/htmlsingle/[RabbitMQ Stream Java Client documentation] for information about configuring the environment and consumer builder.
|
||||
|
||||
@@ -61,7 +57,6 @@ Use of super streams allows for automatic scale-up scale-down with a single acti
|
||||
|
||||
Configuration example:
|
||||
|
||||
====
|
||||
[source, java]
|
||||
----
|
||||
@Bean
|
||||
@@ -69,9 +64,7 @@ public Consumer<Thing> input() {
|
||||
...
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
====
|
||||
[source, properties]
|
||||
----
|
||||
spring.cloud.stream.bindings.input-in-0.destination=super
|
||||
@@ -81,7 +74,6 @@ spring.cloud.stream.bindings.input-in-0.consumer.concurrency=3
|
||||
spring.cloud.stream.rabbit.bindings.input-in-0.consumer.container-type=STREAM
|
||||
spring.cloud.stream.rabbit.bindings.input-in-0.consumer.super-stream=true
|
||||
----
|
||||
====
|
||||
|
||||
The framework will create a super stream named `super`, with 9 partitions.
|
||||
Up to 3 instances of this application can be deployed.
|
||||
|
||||
@@ -9,7 +9,6 @@ IMPORTANT: The producer properties described above are not supported when you se
|
||||
To configure the binder to use a stream `ProducerType`, Spring Boot will configure an `Environment` `@Bean` from the applicaation properties.
|
||||
You can, optionally, add a customizer to customize the message handler.
|
||||
|
||||
====
|
||||
[source, java]
|
||||
----
|
||||
@Bean
|
||||
@@ -24,7 +23,6 @@ ProducerMessageHandlerCustomizer<MessageHandler> handlerCustomizer() {
|
||||
};
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
Refer to the https://rabbitmq.github.io/rabbitmq-stream-java-client/stable/htmlsingle/[RabbitMQ Stream Java Client documentation] for information about configuring the environment and producer builder.
|
||||
|
||||
@@ -40,7 +38,6 @@ IMPORTANT: The super stream must already exist; creating a super stream is not s
|
||||
|
||||
Publishing to a super stream over AMQP:
|
||||
|
||||
====
|
||||
[source, properties]
|
||||
----
|
||||
spring.cloud.stream.bindings.output.destination=super
|
||||
@@ -48,11 +45,9 @@ spring.cloud.stream.bindings.output.producer.partition-count=3
|
||||
spring.cloud.stream.bindings.output.producer.partition-key-expression=headers['cust-no']
|
||||
spring.cloud.stream.rabbit.bindings.output.producer.declare-exchange=false
|
||||
----
|
||||
====
|
||||
|
||||
Publishing to a super stream using the stream client:
|
||||
|
||||
====
|
||||
[source, properties]
|
||||
----
|
||||
spring.cloud.stream.bindings.output.destination=super
|
||||
@@ -62,7 +57,6 @@ spring.cloud.stream.rabbit.bindings.output.producer.producer-type=stream-async
|
||||
spring.cloud.stream.rabbit.bindings.output.producer.super-stream=true
|
||||
spring.cloud.stream.rabbit.bindings.output.producer.declare-exchange=false
|
||||
----
|
||||
====
|
||||
|
||||
When using the stream client, if you set a `confirmAckChannel`, a copy of a successfully sent message will be sent to that channel.
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ Starting with version 3.0, any such batch can be presented as a `List<?>` to the
|
||||
Starting with version 3.1, the consumer can be configured to assemble multiple inbound messages into a batch which is presented to the application as a `List<?>` of converted payloads.
|
||||
The following simple application demonstrates how to use this technique:
|
||||
|
||||
====
|
||||
[source, properties]
|
||||
----
|
||||
spring.cloud.stream.bindings.input-in-0.group=someGroup
|
||||
@@ -26,9 +25,7 @@ spring.cloud.stream.rabbit.bindings.input-in-0.consumer.enable-batching=true
|
||||
spring.cloud.stream.rabbit.bindings.input-in-0.consumer.batch-size=10
|
||||
spring.cloud.stream.rabbit.bindings.input-in-0.consumer.receive-timeout=200
|
||||
----
|
||||
====
|
||||
|
||||
====
|
||||
[source, java]
|
||||
----
|
||||
@SpringBootApplication
|
||||
@@ -87,16 +84,13 @@ public class Application {
|
||||
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
====
|
||||
[source]
|
||||
----
|
||||
Received 2
|
||||
Thing [field=value1]
|
||||
Thing [field=value2]
|
||||
----
|
||||
====
|
||||
|
||||
The number of messages in a batch is specified by the `batch-size` and `receive-timeout` properties; if the `receive-timeout` elapses with no new messages, a "short" batch is delivered.
|
||||
|
||||
@@ -105,7 +99,6 @@ IMPORTANT: Consumer-side batching is only supported with `container-type=simple`
|
||||
If you wish to examine headers of consumer-side batched messages, you should consume `Message<List<?>>`; the headers are a `List<Map<String, Object>>` in a header `AmqpInboundChannelAdapter.CONSOLIDATED_HEADERS`, with the headers for each payload element in the corresponding index.
|
||||
Again, here is a simple example:
|
||||
|
||||
====
|
||||
[source, java]
|
||||
----
|
||||
@SpringBootApplication
|
||||
@@ -174,14 +167,11 @@ public class Application {
|
||||
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
====
|
||||
[source]
|
||||
----
|
||||
Received 2
|
||||
Thing [field=value1] myHeader=headerValue1
|
||||
Thing [field=value2] myHeader=headerValue2
|
||||
----
|
||||
====
|
||||
|
||||
|
||||
Reference in New Issue
Block a user