Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformer not printing the custom headers set in Processor #1520

Closed
amulrajesh opened this issue Mar 30, 2023 · 3 comments
Closed

Transformer not printing the custom headers set in Processor #1520

amulrajesh opened this issue Mar 30, 2023 · 3 comments

Comments

@amulrajesh
Copy link

amulrajesh commented Mar 30, 2023

Using kafka-connector and kamelets,

I am setting some custom header in Processor,

public class CustomProcessor implements Processor {
  @Override
  public void process(Exchange exchange) throws Exception {
      exchange.getMessage().setHeader("dummy", "dummy");
      exchange.getIn().setHeader("dummy", "dummy");
 }
}

And I am trying to get the header value (from above step) in Transformer,

public class CamelToKafkaHeadersTransform<R extends ConnectRecord<R>> implements
    Transformation<R> {
  @Override
  public R apply(R record) {
      for(Header header : record.headers()) {
            System.out.println(header.key(), header.value());
      }
  }
}

Except the custom header I am able to print other camel header values.

@amulrajesh amulrajesh changed the title Unable to capture header set in Processor from Transformer Transformer not printing the custom headers set in Processor Mar 30, 2023
@squakez squakez transferred this issue from apache/camel-k Mar 31, 2023
@squakez
Copy link

squakez commented Mar 31, 2023

@amulrajesh I've moved the issue in the camel-kafka-connector project where I think you'll receive better support.

@oscerd
Copy link
Contributor

oscerd commented Mar 31, 2023

It needs to be prefixed with CamelHeader.

As reported in the documentation and in the code:

public static final String HEADER_CAMEL_PREFIX = "CamelHeader.";

essentially it needs to CamelHeader.dummy as header name.

@amulrajesh
Copy link
Author

Thanks oscerd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants