如何使用 spring DSL 在骆驼中记录标头值 [英] How can I log a header value in camel using spring DSL

查看:24
本文介绍了如何使用 spring DSL 在骆驼中记录标头值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这看起来应该很简单,请原谅双关语.我正在尝试在 spring DSL 路由中记录骆驼的标头.我已经看到了 Java DSL 的答案,但是我一直在寻找如何让它在 spring DSL 中工作的徒劳无功.我试过了:

This seems like it should be simple, pardon the pun. I'm trying to log a header in camel within a spring DSL route. I've seen the answer for Java DSL but I've been searching in vain for how to make it work in spring DSL. I've tried:

 <log message="ftping $simple{header.CamelFileName}"/>

还有:

 <log message="ftping ${header.CamelFileName}"/>

和其他几个排列/变体,但它们都只是逐字记录该文本(即它们不替换实际的标题名称).

and several other permutations/variations, but all of them simply log that text verbatim (i.e. they do not substitute the actual header name).

我错过了什么?

更新:这是我的 xml 文件的较大部分:

update: here's a larger portion of my xml file:

<split>
    <simple>${body}</simple>
    <setHeader headerName="CamelFileName">
        <simple>${body.batchNumber}.xml</simple>
    </setHeader>
    <log message="SLH - 5 -- marshalling an EFileBatch to XML" loggingLevel="DEBUG" />
    <marshal>
        <jaxb prettyPrint="true" contextPath="generated.gov.nmcourts.ecitation"
                partClass="generated.gov.nmcourts.ecitation.NMCitationEFileBatch"
                partNamespace="EFileBatch" />
    </marshal>

    <log message="SLH - 6 -- xslt transform to add schema location" loggingLevel="DEBUG" />
    <to uri="{{addSchemaLocationXsltUri}}"/>

    <log message="SLH - 7 -- ftp now initiating" loggingLevel="DEBUG" />
    <log message="ftping ${headers.CamelFileName}"/>

    <to uri="{{ftpOdysseyInputPath}}"/>
    <log message="SLH - 8 -- ftp now complete" loggingLevel="DEBUG" />
</split>

推荐答案

前段时间问过这个问题,并意识到我最终找到了答案,所以应该把它贴在这里,以防其他人在搜索中找到这个线程.这有效:

Asked this question some time back, and realized that I eventually found the answer so should post it here in case someone else finds this thread in a search. This works:

<log message="ftping $simple{in.header.CamelFileName}" loggingLevel="DEBUG"/>

这篇关于如何使用 spring DSL 在骆驼中记录标头值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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