DakshinJeeva opened a new pull request, #31415:
URL: https://github.com/apache/camel/pull/31415
# Title
CAMEL-27780: Fix reactive streams worker pool and component configuration
## Problem Summary
This PR addresses three issues in the `camel-reactive-streams` component:
1. **Default worker pool runs a single thread:** The built-in engine uses a
core pool size of `0` and a maximum pool size of `10`. With the default bounded
queue of 1000, the executor queues tasks instead of creating additional
workers, causing subscriber notifications to be processed by a single thread in
normal circumstances.
2. **JMX attribute issues:**
- `ReactiveStreamsEndpoint.setConcurrentConsumers()` has
`@ManagedAttribute` on the setter, resulting in a write-only JMX attribute.
- The description of `getExchangesRefillLowWatermark()` refers to a
percentage, although the configured value is a fraction between `0` and `1`.
3. **Hardcoded component lookup in CamelPublisher:** The `CamelPublisher`
constructor retrieves the backpressure strategy using the fixed component name
`reactive-streams`. This prevents components registered under custom names from
supplying their configured default strategy and may cause an unintended default
component to be created.
## Solution
### 1. Fix the default worker pool
- Changed the default `threadPoolMinSize` from `0` to `10`, matching the
default `threadPoolMaxSize`.
- Updated the option metadata and descriptions to document the pool behavior
and defaults.
- Regenerated the component metadata JSON.
Why not use SynchronousQueue?
- A SynchronousQueue has no capacity to buffer tasks. When all worker
threads are busy, newly submitted tasks cannot be queued and may be rejected
depending on the executor's rejection policy.
### 2. Fix JMX attributes and descriptions
- Added `@ManagedAttribute` to `getConcurrentConsumers()` so the JMX
attribute is readable as well as writable.
- Updated the low-watermark description to specify that the value is a
fraction between `0` and `1`, rather than a percentage.
### 3. Remove the hardcoded component lookup
- Changed `CamelPublisher` to receive the
`ReactiveStreamsBackpressureStrategy` directly through its constructor.
- Passed the configured strategy from `ReactiveStreamsComponent` through
`ReactiveStreamsHelper`, the service factory, and
`DefaultCamelReactiveStreamsService`.
- Added a backward-compatible three-argument factory method using a default
interface implementation, preserving existing custom factory implementations.
- Retained the existing endpoint-level backpressure strategy override
behavior.
## Test Cases
- Added a regression test,
`testCustomComponentNameUsesConfiguredBackpressureStrategy`, in
`CamelPublisherTest`.
- Registers a Reactive Streams component under a custom name with the
`LATEST` strategy.
- Registers a separate default `reactive-streams` component with the
default `BUFFER` strategy.
- Verifies that the publisher created by the custom component uses
`LATEST`, rather than incorrectly retrieving `BUFFER` from the default
component.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]