我有一个类似的代码 -
// 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();
Run Code Online (Sandbox Code Playgroud)
但我在日志中得到的是 -
severity="INFO " thread="Camel (camel-1) thread #123 - seda://insert" category="route2" Successfully indexed document id [header{DOC_ID}]
Run Code Online (Sandbox Code Playgroud)
我没有得到实际的标题值(文档 ID)。
所以我的问题是 - 如何在此处访问 Java DSL 中的标头?
DSL 中的日志使用简单的语言:http : //camel.apache.org/simple。
所以你需要这样做:
.log(LoggingLevel.INFO, "Successfully indexed document id [${header." + BatchHeaders.DOCUMENT_ID + "}]")
Run Code Online (Sandbox Code Playgroud)
例如,${header.xxx}在运行时由简单语言评估。
| 归档时间: |
|
| 查看次数: |
16372 次 |
| 最近记录: |