How to get (get) the camel header in java dsl

I have a code, for example -

// use streaming to increase index throughput .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_INSERT_STREAMING)) // define solr endpoint and options .to("solr://" + getSolrEndPoint() + "?defaultMaxConnectionsPerHost=500&streamingThreadCount=500&maxRetries=3") .log(LoggingLevel.INFO, "Successfully indexed document id [" +header(BatchHeaders.DOCUMENT_ID) +"]") // end this route .end(); 

But what I get in the magazine -

 severity="INFO " thread="Camel (camel-1) thread #123 - seda://insert" category="route2" Successfully indexed document id [header{DOC_ID}] 

I do not get the actual value of the header (document id).
So my question is: how to access headers in Java DSL here?

+2
source share
1 answer

The DSL log uses a simple language: http://camel.apache.org/simple

So you need to do it like this:

 .log(LoggingLevel.INFO, "Successfully indexed document id [${header." + BatchHeaders.DOCUMENT_ID + "}]") 

for example, $ {header.xxx} is evaluated at runtime in a simple language.

+3
source

Source: https://habr.com/ru/post/954086/


All Articles