oscerd commented on issue #1507:
URL:
https://github.com/apache/camel-kafka-connector/issues/1507#issuecomment-6632191641
Sorry this went unanswered. This works on 4.22.x without changing the
connector: Kafka record headers whose name starts with `CamelHeader.` become
Camel headers, and the HTTP producer appends the `CamelHttpPath` header to
`camel.sink.path.httpUri` (`CamelHttpQuery` and `CamelHttpUri` do the same for
the query string and the whole URI). To take the value from the record itself
you can use Kafka Connect's built-in `HeaderFrom` SMT, for example:
```properties
camel.sink.path.httpUri=localhost:9200/api/messages
transforms=path
transforms.path.type=org.apache.kafka.connect.transforms.HeaderFrom$Value
transforms.path.fields=guid
transforms.path.headers=CamelHeader.CamelHttpPath
transforms.path.operation=copy
```
With this, the record `{"guid": "abcdefg"}` is sent to
`.../api/messages/abcdefg` (if the value arrives as a map, for example from the
`JsonConverter` with `schemas.enable=false`, also set
`camel.sink.marshal=jackson` so the body is sent as JSON). Because these
headers decide where the request goes, only rely on them when the producers of
the topic are trusted; otherwise block them with
`camel.remove.headers.pattern=CamelHttp.*` (see
https://camel.apache.org/camel-kafka-connector/next/user-guide/remove-headers.html).
Closing this as answered; if it does not work for you on 4.22.x, please open a
new issue with your configuration.
---
_Claude Code on behalf of Andrea Cosentino_
--
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]