Fix IntegrationFlowContext concurrency issue
When we register `IntegrationFlow` s concurrently at runtime, we may end up with the problem when we register the same object with the same bean name, but in different places. Or when we turn off bean overriding, we end up with the exception that bean with the name already registered * Wrap `IntegrationFlow` bean registration in the `StandardIntegrationFlowContext` into the `Lock` when its bean name is generating * Make `StandardIntegrationFlowContext.registry` as `ConcurrentHashMap` to avoid `ConcurrentModificationException` during `put()` and `remove()` * Fix concurrency for beans registration with the generation names in the `IntegrationFlowBeanPostProcessor` using an `IntegrationFlow` id as a prefix for uniqueness. **Cherry-pick to 5.0.x** Fix generated bean name in the WebFluxDslTests Use only single `Lock` in the `StandardIntegrationFlowContext`: we don't need a fully blown `LockRegistry` there anymore since we have only one synchronization block there and it is always around the same type * Add `What's New` note, and mention changes in the `dsl.adoc` Minor doc polishing.
This commit is contained in:
committed by
Gary Russell
parent
a750a7847c
commit
b21dc0dff3
@@ -580,6 +580,12 @@ And Lambda flow can't start from `MessageSource` or `MessageProducer`.
|
||||
|
||||
Starting _version 5.1_, this kind of `IntegrationFlow` are wrapped to the proxy for exposing lifecycle control and provide access to the `inputChannel` of the internally associated `StandardIntegrationFlow`.
|
||||
|
||||
Starting with _version 5.0.5_, the generated bean names for the components in an `IntegrationFlow` include the flow bean followed by a dot as a prefix.
|
||||
For example the `ConsumerEndpointFactoryBean` for the `.transform("Hello "::concat)` in the sample above, will end up with te bean name like `lambdaFlow.org.springframework.integration.config.ConsumerEndpointFactoryBean#0`.
|
||||
The `Transformer` implementation bean for that endpoint will have a bean name such as `lambdaFlow.org.springframework.integration.transformer.MethodInvokingTransformer#0`.
|
||||
These generated bean names are prepended with the flow id prefix for purposes such as parsing logs or grouping components together in some analysis tool, as well as to avoid a race condition when we concurrently register integration flows at runtime.
|
||||
See <<java-dsl-runtime-flows>> for more information.
|
||||
|
||||
[[java-dsl-function-expression]]
|
||||
=== FunctionExpression
|
||||
|
||||
@@ -927,6 +933,10 @@ Usually those additional beans are connection factories (AMQP, JMS, (S)FTP, TCP/
|
||||
Such a dynamically registered `IntegrationFlow` and all its dependant beans can be removed afterwards using `IntegrationFlowRegistration.destroy()` callback.
|
||||
See `IntegrationFlowContext` JavaDocs for more information.
|
||||
|
||||
NOTE: Starting with _version 5.0.5_, all generated bean names in an `IntegrationFlow` definition are prepended with flow id as a prefix.
|
||||
It is recommended to always specify an explicit flow id, otherwise a synchronization barrier is initiated in the `IntegrationFlowContext` to generate the bean name for the `IntegrationFlow` and register its beans.
|
||||
We synchronize on these two operations to avoid a race condition when the same generated bean name may be used for different `IntegrationFlow` instances.
|
||||
|
||||
[[java-dsl-gateway]]
|
||||
=== IntegrationFlow as Gateway
|
||||
|
||||
|
||||
@@ -44,3 +44,9 @@ Previously, interceptors were not applied when beans were created after the appl
|
||||
A new `ResultType.BYTES` mode is introduced for the `ObjectToJsonTransformer`.
|
||||
|
||||
See <<json-transformers>> for more information.
|
||||
|
||||
==== Integration Flows: Generated bean names
|
||||
|
||||
Starting with _version 5.0.5_, generated bean names for the components in an `IntegrationFlow` include the flow bean name, followed by a dot, as a prefix.
|
||||
|
||||
See <<java-dsl-flows>> for more information.
|
||||
|
||||
Reference in New Issue
Block a user