问题
I have a code like -
// 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 m getting in the log is -
severity="INFO " thread="Camel (camel-1) thread #123 - seda://insert" category="route2" Successfully indexed document id [header{DOC_ID}]
I m not getting the actual header value (the document id).
So my question is - How to access the headers in Java DSL here?
回答1:
The log in the DSL uses the 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 + "}]")
eg the ${header.xxx} is evaluated at runtime by the simple language.
来源:https://stackoverflow.com/questions/15111044/how-to-access-get-camel-header-in-java-dsl