[ 
https://issues.apache.org/jira/browse/CAMEL-24935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18118348#comment-18118348
 ] 

Andrea Cosentino commented on CAMEL-24935:
------------------------------------------

PR opened: https://github.com/apache/camel/pull/26783

The body is left alone and the assigned id moves to a new 
CamelPulsarProducerMessageId header. I did not reuse the consumer-side 
MESSAGE_ID constant because its value is the un-prefixed message_id, which 
DefaultHeaderFilterStrategy does not filter.

Verified by reverting the fix: the new test then fails with the body holding 
the MessageId mock.

----
_Claude Code on behalf of oscerd (Andrea Cosentino)._

> camel-pulsar - the producer replaces the message body with the MessageId
> ------------------------------------------------------------------------
>
>                 Key: CAMEL-24935
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24935
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-pulsar
>            Reporter: Andrea Cosentino
>            Assignee: Andrea Cosentino
>            Priority: Minor
>
> h3. Summary
> The producer overwrites the message body with the {{MessageId}} returned by 
> the broker, so after a
> {{to("pulsar:...")}} the original payload is gone for the rest of the route. 
> This is neither documented
> nor covered by a test.
> h3. Details
> {{PulsarProducer.process}}:
> {code:java}
> messageBuilder.sendAsync()
>         .thenAccept(r -> exchange.getIn().setBody(r))
>         .whenComplete(...)
> {code}
> {{r}} is the {{MessageId}} of the published message, and it replaces the IN 
> body. Consequences for an
> ordinary route:
> * any step after the {{to}} sees a {{MessageId}} instead of the payload;
> * {{.to("pulsar:a").to("pulsar:b")}} publishes a serialized {{MessageId}} to 
> the second topic, because
>   {{PulsarProducer.serialize}} falls back to Java serialization when no type 
> converter applies.
> Nothing in {{pulsar-component.adoc}} mentions it and no test asserts it, so 
> it does not look like a
> deliberate contract - but it has been the behaviour for a long time, so a 
> change needs an upgrade-guide
> entry.
> h3. Proposed fix
> Set the send result on the existing {{CamelPulsarMessageId}} header - the 
> same header the consumer
> already populates from {{Message.getMessageId()}} - and leave the body 
> untouched, which is what every
> other Camel producer does. Document the change in the 4.23 upgrade guide.
> A route that today reads the {{MessageId}} from the body would have to read 
> the header instead; that is
> the compatibility cost, and it is worth confirming that trade is acceptable 
> before merging.
> ----
> _Reported by Claude Code on behalf of oscerd (Andrea Cosentino)._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to