Skip to content

CAMEL-24619: Default to Simple consumer type for topic endpoints - #26107

Closed
gnodet wants to merge 2 commits into
apache:mainfrom
gnodet:fix/CAMEL-24619-topic-consumer-oom
Closed

CAMEL-24619: Default to Simple consumer type for topic endpoints#26107
gnodet wants to merge 2 commits into
apache:mainfrom
gnodet:fix/CAMEL-24619-topic-consumer-oom

Conversation

@gnodet

@gnodet gnodet commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

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

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.

The Default consumer type uses DefaultMessageListenerContainer which
repeatedly calls session.createConsumer() on each poll cycle. On some
brokers (e.g. Artemis), this creates a new non-durable queue for each
call that accumulates until the connection is closed, causing OOM on
the broker.

The Simple consumer type uses SimpleMessageListenerContainer which
creates a single persistent consumer, avoiding this issue.

Users can still explicitly set consumerType=Default on topic endpoints
if they need the polling behavior.
@gnodet
gnodet force-pushed the fix/CAMEL-24619-topic-consumer-oom branch from 3c86f53 to 780e07a Compare September 4, 2026 06:29
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

✅ Generated files are up to date

An earlier CI run reported uncommitted generated changes; the latest run no longer does.

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm have you reported this to ActiveMQ Artemis instead, it feels like its more a problem on their side than Spring JMS or Camel.

I dont think we should add "hacks" in Camel for this with a component that has been like this for 15+ years and Spring JMS is widely in use as well, and its default behaviour there also.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • catalog/camel-catalog
  • components/camel-activemq
  • components/camel-activemq6
  • components/camel-amqp
  • components/camel-jms
  • dsl/camel-componentdsl
  • dsl/camel-endpointdsl

🔬 Scalpel shadow comparison — Scalpel: 15 tested, 24 compile-only — current: 12 all tested

Maveniverse Scalpel detected 39 affected modules (current approach: 12).

⚠️ Modules only in Scalpel (27)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 15 modules (7 direct + 8 downstream), skip tests for 24 (generated code, meta-modules)

Modules Scalpel would test (15)
  • camel-activemq
  • camel-activemq6
  • camel-amqp
  • camel-catalog
  • camel-componentdsl
  • camel-endpointdsl
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-jms
  • camel-launcher-container
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (24)
  • apache-camel
  • camel-allcomponents
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • components/camel-jms: 3 test(s) disabled on GitHub Actions
All tested modules (39 modules)
  • Camel :: AMQP
  • Camel :: ActiveMQ 5.x
  • Camel :: ActiveMQ 6.x
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: JMS
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@gnodet

gnodet commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Closing this PR — after investigation with Torsten Mielke and the reporter on CAMEL-24619, the root cause is a misconfigured Artemis broker (missing deleteNonDurableQueue permission), not a Camel bug.

With the default CACHE_CONSUMER setting, DefaultMessageListenerContainer creates the consumer once and reuses it for the entire route lifetime. Even with lower cache levels (CACHE_CONNECTION), Artemis correctly cleans up non-durable queues when the consumer disconnects — provided the broker permissions are correct.

No change needed in Camel.

@gnodet gnodet closed this Sep 4, 2026
@gnodet
gnodet deleted the fix/CAMEL-24619-topic-consumer-oom branch September 4, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants