oscerd opened a new pull request, #26783:
URL: https://github.com/apache/camel/pull/26783
## What
`PulsarProducer.process` did:
```java
messageBuilder.sendAsync()
.thenAccept(r -> exchange.getIn().setBody(r))
```
`r` is the `MessageId` the broker assigned, and it replaced the IN body. So
after a `to("pulsar:...")`:
* every later step in the route saw a `MessageId` instead of the payload it
had just sent;
* `.to("pulsar:a").to("pulsar:b")` published a **Java-serialized
`MessageId`** to the second topic,
because `PulsarProducer.serialize` falls back to `ObjectOutputStream` when
no type converter applies.
Nothing in `pulsar-component.adoc` mentioned it and no test covered it, so
it does not read as a
deliberate contract — but it has been the behaviour for a long time, hence
the upgrade-guide entry.
## Change
Leave the body untouched and report the assigned id on a new header,
`CamelPulsarProducerMessageId`, named the same way as the producer headers
this component already has
(`CamelPulsarProducerMessageKey`, `CamelPulsarProducerMessageEventTime`, …).
I deliberately did **not** reuse the existing consumer-side `MESSAGE_ID`
constant: its value is the
un-prefixed `message_id`, which `DefaultHeaderFilterStrategy` does not
filter, and adding a producer
meaning to it would spread that name rather than contain it.
## Compatibility
A route that today reads the `MessageId` from the body has to read the
header instead. That is the whole
cost, and it is in the guide. If you would rather keep the body assignment
and only add the header, say
so — but then `.to("pulsar:a").to("pulsar:b")` keeps publishing a serialized
`MessageId`, which seems
worse than the break.
## Test
`PulsarProducerMessageIdHeaderTest` sends through a mocked `PulsarClient`
(Mockito `RETURNS_SELF` for the
fluent `ProducerBuilder` and `TypedMessageBuilder`) and asserts the body
survives and the header carries
the id. Verified by reverting the fix: it then fails with *"the producer
should leave the body alone …
but was: Mock for MessageId"*.
Module unit suite green (24 tests); full reactor `mvn clean install
-DskipTests -DskipITs` green, which is
what regenerated the catalog and the endpoint DSL for the new header.
_Claude Code on behalf of oscerd_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]