gnodet opened a new pull request, #26107:
URL: https://github.com/apache/camel/pull/26107

   ## Summary
   
   When consuming from a JMS topic (`pubSubDomain=true`) and the user has not 
explicitly set a `consumerType`, the consumer type is now automatically set to 
`Simple` instead of `Default`.
   
   ## Problem
   
   The `Default` consumer type uses Spring's `DefaultMessageListenerContainer` 
which repeatedly calls `session.createConsumer()` on each poll cycle. On some 
brokers (e.g. Apache Artemis), this creates a new non-durable queue for each 
call on multicast addresses (topics). These queues accumulate until the 
connection is closed, causing **OutOfMemoryError on the broker**.
   
   The workaround was to explicitly set `consumerType=Simple` in the URI, but 
the default behavior was dangerous for topic consumers.
   
   ## Fix
   
   - In `JmsConfiguration.createMessageListenerContainer()`, when the endpoint 
is a topic and `consumerType` was not explicitly set by the user, automatically 
use `Simple` instead of `Default`
   - Track whether `consumerType` was explicitly set via a 
`consumerTypeExplicitlySet` flag
   - Log an INFO message when the auto-switch happens, so users are aware
   - Users can still explicitly set `consumerType=Default` on topic endpoints 
if they need the polling behavior
   - Updated the `@UriParam` description to document this topic-aware defaulting
   
   ## Changes
   
   - `JmsConfiguration.java`: Added `consumerTypeExplicitlySet` tracking flag, 
topic-aware logic in `createMessageListenerContainer()`, updated description
   - `JmsEndpointConfigurationTest.java`: Updated 
`testCacheConsumerEnabledForTopic` to reflect new behavior, added 4 new tests:
     - `testTopicConsumerDefaultsToSimple` - topic with no explicit type → 
Simple
     - `testQueueConsumerStillDefaultsToDefault` - queue unchanged → Default
     - `testTopicConsumerExplicitDefault` - topic with explicit Default → 
Default (respected)
     - `testTopicConsumerExplicitSimple` - topic with explicit Simple → Simple
   
   ## Backward Compatibility
   
   - **Queue endpoints**: No change — still default to `Default` consumer type
   - **Topic endpoints without explicit consumerType**: Now use `Simple` 
(behavioral change, but fixes a bug that caused OOM)
   - **Topic endpoints with explicit `consumerType=Default`**: Unchanged — 
explicit user setting is respected
   
   Fixes: https://issues.apache.org/jira/browse/CAMEL-24619


-- 
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]

Reply via email to