Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How setHeader() works in Apache camel

I was going through some documentation on Apache Camel and not able to understand what setHeader() does in Apache Camel. Does it add a header to the file specified within from. And also suggest some link where I can get tutorial on Apache Camel.

like image 804
RoyalTiger Avatar asked Nov 16 '16 03:11

RoyalTiger


People also ask

What is Camel SetHeader?

The SetHeader EIP is used for setting a message header.

How does Camel framework work?

Apache Camel is an open source integration framework designed to make integrating systems simple and easy. It allows end users to integrate various systems using the same API, providing support for multiple protocols and data types, while being extensible and allowing the introduction of custom protocols.

What is CamelContext in Apache Camel?

The CamelContext is the runtime system, which holds everything together as depicted in the figure below. The CamelContext provides access to many useful services, the most notable being components, type converters, a registry, endpoints, routes, data formats, and languages. Contains the components used.

What is Java DSL in Camel?

Camel uses a Java Domain Specific Language or DSL for creating Enterprise Integration Patterns or Routes in a variety of domain-specific languages (DSL) as listed below: Java DSL - A Java based DSL using the fluent builder style.


2 Answers

No, it does not add anything to a file. .setHeader() creates a header that exist within the current route. You can create a header like .setHeader("myHeader", "myHeaderValue"). Use headers to access dynamic properties during your route by .getHeader("myHeader") For more long lasting property use exchange properties.

like image 90
Souciance Eqdam Rashti Avatar answered Oct 07 '22 01:10

Souciance Eqdam Rashti


setHeader to a file(message) consumed(from) does not set the header to the file.

Camel File2 check the Message Headers. This lists all the Message Headers supported for produce(to) and consume(from) of File endpoint. For a file consumed, you can access the (getHeader) supported headers in the message. But overwriting these values does not overwrite the meta data of the file though.

Headers and Properties in Apache Camel can be used interchangeably to pass values between processes in a single route, but when you want to carry across different routes the behaviors differs. Headers can be lost at endpoints basically as they usually represent some component specific things. Go through the document to understand further.

Best tutorials for Camel - Apache Camel Books and Apache Cammel Documentation

like image 28
Sagar Avatar answered Oct 07 '22 01:10

Sagar