davsclaus opened a new pull request, #3345:
URL: https://github.com/apache/camel-kamelets/pull/3345
Hardening of the default of the JMS source Kamelets: an answer goes only to
the `JMSReplyTo` of the incoming message, and headers set during the flow do
not change the answer.
## What camel-jms does today
I checked `EndpointMessageListener` and `JmsBinding` on Camel main, and ran
it against Artemis, ActiveMQ Classic and IBM MQ:
- **Where the answer goes is decided before the flow runs.** The listener
takes the reply destination from the endpoint's `replyTo` option, or else from
the `JMSReplyTo` of the incoming JMS message. Only when there is one does the
exchange become request-reply, and the answer is sent to that destination after
the flow.
- **(a)** A message without `JMSReplyTo` gets no answer, even when the
flow sets a `JMSReplyTo`, `CamelJmsDestinationName` or `CamelJmsDestination`
header.
- **(b)** With a `JMSReplyTo` on the incoming message, such headers set in
the flow do not move the answer: it still goes to the original queue, and
nothing reaches the other one.
- **(c)** `replyTo` is a fixed override that the operator sets on the
endpoint; these Kamelets do not set it. `preserveMessageQos` applies to
sending, not to choosing the reply destination.
- **The flow can still shape the answer message itself.** A `JMSReplyTo`
header that the flow sets is written into the `JMSReplyTo` field of the answer.
On Artemis a queue name given as text was dropped, so the answer carried no
`JMSReplyTo`. On IBM MQ the answer failed to send (`MQRC_MISSING_REPLY_TO_Q`),
so the requester got no answer.
- **The same holds for all three sources.** `jms-amqp-10-source` and
`jms-ibm-mq-source` honour `JMSReplyTo` today exactly as
`jms-apache-artemis-source` does: they use the same `jms` consumer with no
reply option. Checked with the new tests run against the current Kamelets: each
sent the answer to the `JMSReplyTo` queue of the request.
## The change
`jms-apache-artemis-source`, `jms-amqp-10-source` and `jms-ibm-mq-source`:
- Keep the `JMSReplyTo` of the incoming message in a variable before the
flow, and set it back after the flow.
- Remove the `CamelJms*` headers the flow set, so they do not affect how the
answer is sent.
- Say in "Good to know": an answer is sent only when the incoming message
has a `JMSReplyTo`, and goes back to that queue. Headers set during the flow
cannot send it to another queue, nor make one for a message without
`JMSReplyTo`.
Request-reply keeps working, so the default changes only for a flow that
sets these headers. The same change goes into the new
`jms-apache-activemq-source` in #3342.
## Tests
A new Citrus test for each source, `jms/<source>-reply-route`: Artemis for
`jms-apache-artemis-source`, Artemis over AMQP 1.0 for `jms-amqp-10-source`,
and IBM MQ for `jms-ibm-mq-source`. In each flow, the source sets `JMSReplyTo`
and `CamelJmsDestinationName` to another queue. Each test checks:
1. A request with `JMSReplyTo` gets its answer on that queue, and the answer
carries the `JMSReplyTo` of the request.
2. A request without `JMSReplyTo` gets no answer.
3. Another request-reply, so that request 2 is done.
4. Nothing reached the other queue: a poll with a 3-second timeout finds it
empty.
Local results: `./mvnw -o clean install -DskipITs` passes.
`MessagingIT#jms`: 9 of 9 pass: the 3 new reply tests and the 6 existing
Artemis, AMQP 1.0 and IBM MQ tests. Before the template change, the same tests
(an earlier version that checked only that a request without `JMSReplyTo` gets
no answer) showed that all three sources send the answer to `JMSReplyTo`; the
version run against the old Artemis template showed the answer losing its
`JMSReplyTo`.
Fixes #3344.
## Upgrade note
```
The JMS source Kamelets (`jms-apache-artemis-source`, `jms-amqp-10-source`,
`jms-ibm-mq-source`, `jms-apache-activemq-source`) send an answer only to the
`JMSReplyTo` of the incoming message, as before, and now put that `JMSReplyTo`
back on the answer and remove the `CamelJms*` headers after the flow: a flow
can no longer change the `JMSReplyTo` or the `CamelJms*` headers of the answer.
Request-reply is unchanged.
```
_Claude Code on behalf of Claus Ibsen_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
--
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]