簡體   English   中英

如何使用spring DSL在camel中記錄標頭值

[英]How can I log a header value in camel using spring DSL

這似乎應該很簡單,原諒雙關語。 我正試圖在Spring DSL路線中記錄駱駝的標題。 我已經看到了Java DSL的答案,但我一直在尋找如何使它在Spring DSL中工作的徒勞。 我試過了:

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

並且:

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

和其他幾個排列/變體,但所有這些只是簡單地記錄該文本(即它們不替代實際的標題名稱)。

我錯過了什么?


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

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

回過頭來問這個問題,並意識到我最終找到了答案所以應該在這里發布,以防其他人在搜索中找到這個帖子。 這有效:

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

嘗試以下方法,可以使用:

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

在Camel 2.5中添加了$simple{...}語法,以避免與Spring ${...}發生沖突 - 可能是您使用的是舊版本?

在JAVA DSL中

from("logger")
.log(LoggingLevel.INFO, "${in.headers.CamelFileName}")
.end

LoggingLevel來自org.apache.camel.LoggingLevel

不確定是否可能

http://camel.apache.org/logeip.html

記錄DSL和日志組件之間的區別日志DSL更輕,用於記錄人類日志,如開始做...等。它只能記錄基於簡單語言的消息。

另一方面,Log組件是一個完整的組件,涉及使用端點等.Log組件用於記錄Message本身,並且您有許多URI選項來控制您想要記錄的內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM