Skip to content

CAMEL-23676: Fix NatsProducerReplyToIT and NatsConsumerWithRedeliveryIT tests#23811

Merged
davsclaus merged 1 commit into
apache:mainfrom
ammachado:CAMEL-23676
Jun 7, 2026
Merged

CAMEL-23676: Fix NatsProducerReplyToIT and NatsConsumerWithRedeliveryIT tests#23811
davsclaus merged 1 commit into
apache:mainfrom
ammachado:CAMEL-23676

Conversation

@ammachado
Copy link
Copy Markdown
Contributor

Description

Fix two integration tests broken by CAMEL-23676 (camel-nats - Only send reply when exchange pattern is InOut).

That commit changed NatsConsumer to only publish a reply to msg.getReplyTo() when exchange.getPattern().isOutCapable(). Since NatsEndpoint defaults to InOnly, consumer exchanges are InOnly by default and the reply is never published unless the endpoint URI explicitly sets exchangePattern=InOut.

Both failing tests use template.requestBody(...), which creates an InOut exchange on the producer side. The NATS producer therefore calls connection.request(), attaching a reply-to inbox to the message. The consumer receives the message, but because its exchange is InOnly, the isOutCapable() check fails and the reply is never sent. The producer then blocks until the 20-second requestTimeout fires, causing the test to fail with an ExchangeTimedOutException.

Changes:

  • NatsProducerReplyToIT: add ?exchangePattern=InOut to the consumer route URI so the consumer creates InOut exchanges and the reply is published back to the producer.
  • NatsConsumerWithRedeliveryIT: switch from template.requestBody(...) to template.sendBody(...). The test only checks that messages reach mock:result and mock:exception; it never inspects the reply value. Using sendBody creates an InOnly exchange, so the NATS producer calls connection.publish() (no reply-to) and the consumer processes the message without needing to reply.

This pattern is consistent with NatsConsumerReplyToIT and NatsConsumerReplyToInOnlyIT introduced by CAMEL-23676 to demonstrate correct usage of the new behavior.

Claude Code on behalf of Adriano Machado

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

Both tests broke after CAMEL-23676 changed NatsConsumer to only publish
a reply when the exchange pattern is InOut.

- NatsProducerReplyToIT: add ?exchangePattern=InOut to the consumer URI
  so the consumer creates InOut exchanges and publishes the reply.
- NatsConsumerWithRedeliveryIT: switch from requestBody to sendBody since
  the test only asserts mock delivery, not reply content. This avoids the
  request/reply handshake entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ammachado ammachado marked this pull request as ready for review June 6, 2026 22:38
@ammachado ammachado changed the title CAMEL-23676: Fix NatsProducerReplyToIT and NatsConsumerWithRedeliveryIT CAMEL-23676: Fix NatsProducerReplyToIT and NatsConsumerWithRedeliveryIT tests Jun 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 7, 2026

🌟 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
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 7, 2026

🧪 CI tested the following changed modules:

  • components/camel-nats
All tested modules (8 modules)
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher :: Container
  • Camel :: Nats
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@davsclaus davsclaus merged commit 106f84d into apache:main Jun 7, 2026
5 checks passed
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