GH-3450: Expose PubSub requireSubscribers option (#3459)
* GH-3450: Expose PubSub requireSubscribers option Fixes https://github.com/spring-projects/spring-integration/issues/3450 * Add `PublishSubscribeChannel` ctors with the `requireSubscribers` option with a direct delegation to the same option of underlying `BroadcastingDispatcher` * Add factory methods to the `Channels` & `MessageChannels` to expose this new `requireSubscribers` option * Expose an XML `require-subscribers` attribute for the `<publish-subscribe-channel` * Document this new `requireSubscribers` option * Introduce a global `spring.integration.channels.error.requireSubscribers` property for a default `errorChannel` * Document this property and explain its default `true` in the `error-handling.adoc` * Remove docs for `spring.integration.postProcessDynamicBeans` since it purpose was removed since version `5.1` in favor of "always post-process behavior" as it was always with all the `BeanPostProcessor`s * * Fix language in docs according review * * Add more docs about `requireSubscribers` and cross-links between chapters
This commit is contained in:
@@ -794,6 +794,9 @@ public MessageChannel pubsubChannel() {
|
||||
NOTE: The `apply-sequence` value is `false` by default so that a publish-subscribe channel can send the exact same message instances to multiple outbound channels.
|
||||
Since Spring Integration enforces immutability of the payload and header references, when the flag is set to `true`, the channel creates new `Message` instances with the same payload reference but different header values.
|
||||
|
||||
Starting with version 5.4.3, the `PublishSubscribeChannel` can also be configured with the `requireSubscribers` option of its `BroadcastingDispatcher` to indicate that this channel will not ignore a message silently when it has no subscribers.
|
||||
A `MessageDispatchingException` with a `Dispatcher has no subscribers` message is thrown when there are no subscribers and this option is set to `true`.
|
||||
|
||||
[[channel-configuration-executorchannel]]
|
||||
===== `ExecutorChannel`
|
||||
|
||||
@@ -1017,9 +1020,6 @@ To inject a global interceptor before the existing interceptors, use a negative
|
||||
NOTE: Note that both the `order` and `pattern` attributes are optional.
|
||||
The default value for `order` will be 0 and for `pattern`, the default is '*' (to match all channels).
|
||||
|
||||
Starting with version 4.3.15, you can configure the `spring.integration.postProcessDynamicBeans = true` property to apply any global interceptors to dynamically created `MessageChannel` beans.
|
||||
See <<./configuration.adoc#global-properties,Global Properties>> for more information.
|
||||
|
||||
[[channel-wiretap]]
|
||||
===== Wire Tap
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ spring.integration.taskScheduler.poolSize=10 <4>
|
||||
spring.integration.messagingTemplate.throwExceptionOnLateReply=false <5>
|
||||
spring.integration.readOnly.headers= <6>
|
||||
spring.integration.endpoints.noAutoStartup= <7>
|
||||
spring.integration.postProcessDynamicBeans=false <8>
|
||||
spring.integration.channels.error.requireSubscribers=true <8>
|
||||
----
|
||||
|
||||
<1> When true, `input-channel` instances are automatically declared as `DirectChannel` instances when not explicitly found in the application context.
|
||||
@@ -196,8 +196,9 @@ You can manually start these endpoints later by their bean name through a `Contr
|
||||
You can explicitly override the effect of this global property by specifying `auto-startup` XML annotation or the `autoStartup` annotation attribute or by calling `AbstractEndpoint.setAutoStartup()` in the bean definition.
|
||||
Since version 4.3.12.
|
||||
|
||||
<8> A boolean flag to indicate that `BeanPostProcessor` instances should post-process beans registered at runtime (for example, message channels created by `IntegrationFlowContext` can be supplied with global channel interceptors).
|
||||
Since version 4.3.15.
|
||||
<8> A boolean flag to indicate that default global `errorChannel` must be configured with the `requireSubscribers` option.
|
||||
Since version 5.4.3.
|
||||
See <<./error-handling.adoc#error-handling,Error Handling>> for more information.
|
||||
====
|
||||
|
||||
These properties can be overridden by adding a `/META-INF/spring.integration.properties` file to the classpath.
|
||||
|
||||
@@ -70,3 +70,8 @@ With Java & Annotation configuration, a resource is a `@Configuration` class and
|
||||
In most case the target integration flow solution is based on the out-of-the-box components and their configuration options.
|
||||
When an exception happens at runtime, there is no any end-user code involved in stack trace because an execution is against beans, not their configuration.
|
||||
Including a resource and source of the bean definition helps to determine possible configuration mistakes and provides better developer experience.
|
||||
|
||||
Starting with version 5.4.3, the default error channel is configured with the property `requireSubscribers = true` to not silently ignore messages when there are no subscribers on this channel (e.g. when application context is stopped).
|
||||
In this case a `MessageDispatchingException` is thrown which may lend on the client callback of the inbound channel adapter to negatively acknowledge (or roll back) an original message in the source system for redelivery or other future consideration.
|
||||
To restore the previous behavior (ignore non dispatched error messages), the global integration property `spring.integration.channels.error.requireSubscribers` must be set to `false`.
|
||||
See <<./configuration.adoc#global-properties,Global Properties>> and <<./channel.adoc#channel-configuration-pubsubchannel,`PublishSubscribeChannel` Configuration>> (if you configure a global `errorChannel` manually) for more information.
|
||||
|
||||
Reference in New Issue
Block a user