如何访问(GET)在Java DSL骆驼头 [英] How to access (get) camel header in java dsl

查看:126
本文介绍了如何访问(GET)在Java DSL骆驼头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个code一样 -

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();

但我m到处在日志中 -

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}]

我不是得到实际的标头值(文档编号)。结果
所以我的问题是 - 如何访问头在Java中的DSL这里

I m not getting the actual header value (the document id).
So my question is - How to access the headers in Java DSL here?

推荐答案

在日志中的DSL使用简单的语言: http://camel.apache.org/simple

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

所以,你需要做这样

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

如$ {} header.xxx通过简单的语言在运行时进行评估。

eg the ${header.xxx} is evaluated at runtime by the simple language.

这篇关于如何访问(GET)在Java DSL骆驼头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆