如何在JAXWS SOAP中启用故障切换功能时进行报告?

huangapple go评论67阅读模式
英文:

How to report when failover feature is active in JAXWS SOAP?

问题

我有一个客户端,构建如下:

val strategy = new SequentialStrategy()
strategy.setAlternateAddresses(listOfAddresses)

val feature = new CircuitBreakerFailoverFeature(2, 60000)
feature.setStrategy(strategy)

val factory = new JaxWsProxyFactoryBean()
factory.setServiceClass(classOf[MyService])
factory.setAddress(primaryAddress)
factory.setFeatures(Lists.newArrayList(feature))
factory.create().asInstanceOf[MyService]

我现在遇到的问题是,当我的客户端由于与primaryAddress的连接问题而实际访问了其中一个alternative地址时,我需要向监控工具报告。但我找不到检测地址之间切换的方法(我考虑添加自定义拦截器,但我确信有更好的方法)。正确的做法是什么?

英文:

I have a client that is built like this:

val strategy = new SequentialStrategy()
strategy.setAlternateAddresses(listOfAddresses)

val feature = new CircuitBreakerFailoverFeature(2, 60000)
feature.setStrategy(strategy)

val factory = new JaxWsProxyFactoryBean()
factory.setServiceClass(classOf[MyService])
factory.setAddress(primaryAddress)
factory.setFeatures(Lists.newArrayList(feature))
factory.create().asInstanceOf[MyService]

The problem I have now is that I need to report to monitoring tool when my client is actually went to one of alternative addresses as result of problem with connection to the primaryAddress. But I can't find the way how to detect those switches between addresses (I thought about adding custom interceptors, but I bet there is a better way to do it). What is the correct way of doing so?

答案1

得分: 0

看起来更或多或少是正确的方法是将报告逻辑注入到TargetSelector中,就像这样:

class MonitoredCircuitBreakerTargetSelector(errorReporter: Monitoring) extends CircuitBreakerTargetSelector {
  @Override
  protected void onFailure(context: FailoverTargetSelector#InvocationContext, ex: Exception)= {
    errorReporter.report("...")
    super.onFailure(context, ex)
  }
}

然后在FailoverFeature上调用feature.setTargetSelector(new MonitoredCircuitBreakerTargetSelector(errorReporter))

英文:

Looks like more or less a correct way to do this is to inject reporting logic into TargetSelector, like this:

class MonitoredCircuitBreakerTargetSelector(errorReporter: Monitoring) extends CircuitBreakerTargetSelector {
  @Override
  protected void onFailure(context: FailoverTargetSelector#InvocationContext, ex: Exception)= {
    errorReporter.report(s"...")
    super.onFailure(context, ex)
  }
}

and then call feature.setTargetSelector(new MonitoredCircuitBreakerTargetSelector(errorReporter)) on FailoverFeature

huangapple
  • 本文由 发表于 2020年8月5日 00:24:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/63251125.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定