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