【问题标题】:Logging from the Spring Integration DSL to the database从 Spring Integration DSL 记录到数据库
【发布时间】:2018-10-03 12:26:18
【问题描述】:

我正在使用 Spring Integration Java DSL 开发应用程序。

使用应用程序中的 Spring Data JPA 登录数据库的最佳方式是什么?

我与多个 HTTP 获取和发布有相当长的集成流程。我希望至少记录发送和响应的消息以及使用了哪些 URL 以及可能的其他一些自定义值。

我已尝试使用IntegrationFlowBuilder.log 方法进行日志记录。有了这个我的计划是创建一些自定义记录器,它记录到数据库中。

我已经尝试使用IntegrationFlowBuilder.enrichHeaders 方法和IntegrationFlowBuilder.log 方法来记录URLS 和其他自定义值。如何更改IntegrationFlowBuilder 中的某些标题条目?我添加了具有相同键和不同值的条目,但日志记录中的值没有改变。

【问题讨论】:

    标签: spring spring-integration spring-integration-dsl


    【解决方案1】:

    enrichHeaders()HeaderEnricherSpec 提供如下选项:

    /**
     * Determine the default action to take when setting individual header specifications
     * without an explicit 'overwrite' argument.
     * @param defaultOverwrite the defaultOverwrite.
     * @return the header enricher spec.
     * @see HeaderEnricher#setDefaultOverwrite(boolean)
     */
    public HeaderEnricherSpec defaultOverwrite(boolean defaultOverwrite) {
    

    此外,每个添加到标题中的条目都可以使用自己的override 标志指定:

    /**
     * Add a single header specification where the value is a String representation of a
     * SpEL {@link Expression}.
     * @param name the header name.
     * @param expression the expression.
     * @param overwrite true to overwrite an existing header.
     * @return the header enricher spec.
     */
    public HeaderEnricherSpec headerExpression(String name, String expression, Boolean overwrite) {
    

    【讨论】:

      猜你喜欢
      • 2017-12-22
      • 2018-03-24
      • 1970-01-01
      • 1970-01-01
      • 2019-06-29
      • 2017-12-23
      • 1970-01-01
      • 1970-01-01
      • 2015-01-29
      相关资源
      最近更新 更多