【问题标题】:how to implement analytics in spring integration project?如何在 Spring 集成项目中实现分析?
【发布时间】:2015-04-09 20:19:14
【问题描述】:

我正在从事 Spring 集成项目,我想实施分析。基本思想是捕获所有网关中调用的方法名称、时间戳和次数。

是否有任何默认包/类可用于记录这些详细信息?

这是我想做的事情,在我继续之前需要建议

第一步:添加方法名是网关方法头

<int:gateway id="gateway" service-interface="org.pro.gateway.SampleGateway">
    <int:method name="method1" request-channel="request.input.channel" reply-channel="reply.output.channel">
        <int:header name="methodName" value="placeOrder"/>
    </int:method>
</int:gateway>

第 2 步: 添加 Spring Wire tap 拦截器,应用仅匹配输入通道的模式。在窃听通道中按名称获取消息头并记录。

<int:wire-tap channel="wiretapChannel" pattern="input*" />

<int:service-activator ref="analyticsBean" method="footprint" input-channel="wiretapChannel" output-channel="outputChannel"/>

<bean id="analyticsBean" class="org.pro.stat.AnalyticService"/>

第 3 步: 实施代码

public class AnalyticsService {
   public void footprint(Message<String> msg){
    String methodName = msg.getHeaders().get("methodName");  
    long timestamp = msg.getHeaders().getTimestamp();
    /* Send to some service / store it in file with incremented value */
    storeIt(methodName, timestamp);
}}

【问题讨论】:

    标签: java spring spring-integration


    【解决方案1】:

    您的步骤看起来不错。 但是,为什么不让分析服务使用 @Async(在 spring 中使用任务执行器服务)从而不消耗父线程上的负载。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-28
      • 1970-01-01
      • 1970-01-01
      • 2017-11-11
      • 1970-01-01
      • 2021-01-06
      • 1970-01-01
      相关资源
      最近更新 更多