英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论